Easy method of forcing a browser cache update

For years now, I’ve dealt with the problem of browsers caching external documents (stylesheets and their like) by appending the query symbol (the question mark [?]) to my URLs in the source code. As it’s now a different URL entirely to the browser, the browser will download it again and store the particular resource as a new entry in its cache. When I need to update the files again, I usually append and increment a number after the ?, like so: ?21, where the next would be ?22. Sometimes I feel creative and add a random string after the question mark, rather a boring number. It works great, and it guarantees that your users won’t see an old stylesheet or old JavaScript file with an updated web page.


Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>