Prevent CSS or JS Caching by versioning

Many time it happen that we update the new css on server but we still face problems that user sees the old css.

Use following methodology to prevent this to happen:

This works by applying the file modification date to css file. Browser¬†understand it as different file and loads and then put to cache. until unless dynamic HTML code changes it doesn’t fetch it again.

filename is a PHP function which return timestamp for file modification time.

Output looks like:

All the best :)

Ganesh Bhosale

From a laptop to a full organization, Ganesh has traveled a tough road. A commando, armed with the latest tech & a huge warehouse of knowledge, he leads by example & is here for the long haul. His strong belief in giving back more has borne rich fruits, both for his employees & clients.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *