Back
Apr 3, 2011

Sprite cache invalidation

Vladimir Sidorenko

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:

false
false

Update

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

More thoughts