Sprite cache invalidation

, , django, cache, css, sprites

When we use css-sprites it's important to make browser cache them for longest period possible. On other hand, we need to refresh them when they are updated. This is especially visible when all icons are stored in single sprite. When it's outdated - entire site becomes ugly.

To solve this task I've implemented this small script that adds file's hash to url:

background-image: url(images/icons.png);
background-image: url(images/icons.png?a3844c660);


This is pretty old article. Now it's better to use something integrated to your build process - grunt, webassets, etc.

contact us right now