You never more need to clear cache!

It is a recurring problem, you make an update in a system, and suddenly half the customers have problems with the update and everything is solved with a simple cache clearing. This occurs when a change involves a script, browsers keep a cache of scripts in order to speed up the loading of pages.

Simple solution

To resolve we will not clear the browser cache but do it download the file.

This is how it is usually inserted a script on the page:

<script src="meu_script.js"></script>

Just what we need to do is include a querystring in the src tag:

<script src="meu_script.js?v=2"></script>

Ie every time you change this number the browser will understand that this file is different than what he already has and does not need to clear the cache.

I especially love when the solution is simple :)

Um comentário: