TRAFEX TRAFEX Consultancy Consultancy
Quickly add a cachebuster to @import statements

Quickly add a cachebuster to @import statements

August 16, 2014

This CLI one-liner searches for .css files with @import statements and adds a ‘cache busting’ query string to it. You can use it to make sure the browser picks up the new CSS files when they are included with @import statements.

Snippet

find . -iname *.css -exec sed -i -e 's/@import "(.*).css"/@import "\1.css?cb=12345"/g' {} ;

Before

@import url('//fonts.googleapis.com/css?family=Francois+One');
@import url('/css/layout.css');
@import url('/css/color.css');

After

@import url('//fonts.googleapis.com/css?family=Francois+One');
@import url('/css/layout.css?cb=12345');
@import url('/css/color.css?cb=12345');
Go back

Recent articles

Articles

Checklist: Prepare your website for Go Live

When you’re ready to launch your website or web application, you can use this checklist to be fully prepared for the Go Live and have a smooth transition!

Read More

Articles

The key components of Kubernetes autoscaling

Autoscaling is an important feature of Kubernetes. With this feature you always have enough resources for the workload, and when a node becomes unhealthy it gets replaced without effecting the workload. But you won’t get it automatically by just deploying your Pods on Kubernetes.

Read More

Articles

Create a DB backup from a pod running MySQL on Kubernetes

When using the MySQL docker image you can easily create a DB dump with this one-line CLI command.

Read More