Home / Tutorials / Prevent the browser cache for modified files

Prevent the browser cache for modified files

Browser cache is very useful when users download the same CSS and JS files multiple times. Some browsers, however, use the old CSS and JS files from the cache, even though they have been updated. This may lead to unpleasant situations, when the pages are displayed to the user with the wrong styles or pages will work incorrectly.

Here is a way to avoid these unpleasant situations and let the browsers cache files as long as they are not modified.

Basic example with static HTML-pages

Original CSS ja JS file names:

To avoid cache for updated files use files names like below: 

Lets do more better using php:

OUTPUT:

The best thing of this implementation is that if only one file is changed, then all file names are not changed. So only modified files will be taken from without cache and all other files will be from cache.

 

About cmadmin

Web Developer & Designer | Android App Developer

Check Also

Top Useful CSS Snippets – Every Designer Should Know

With so many new trends advancing every year it can be difficult keeping up with …

css3-media-queries

Media Queries for Standard Devices

A major component of responsive design is creating the right experience for the right device. …

Leave a Reply

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

Login


Username
Create an Account!
Password
Forgot Password? (close)

Sign Up


Username
Email
Password
Confirm Password
Want to Login? (close)

Forget Password?


Username or Email
(close)
%d bloggers like this:
SHARE
OR
SUBSCRIBE
To get latest new / tutorial / technology / development information subscribe with us.
ARE YOU READY? GET IT NOW!
Lets Get Updated with latest trends & tutorials!
Your Information will never be shared with any third party.
Ready for latest tutorials & tools !
OR SUBSCRIBE WITH