Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preventing browser caching on web application upgrades

I have a quite troublesome issue which I didn't find a good solution for yet.

I allow caching of all my application static files (JS, CSS and images) by browser for performance.

Problem is, when I'm doing upgrades, the users still use the old version from their cache, which often breaks the application, and requires clearing the cache every time to solve the problem.

Is there any good multi-browser approach which still allows caching the files, but can force to reload them when needed?

Thanks for any info.

like image 660
SyBer Avatar asked Jan 12 '10 17:01

SyBer


People also ask

How do I stop my browser from caching?

When you're in Google Chrome, click on View, then select Developer, then Developer Tools. Alternatively, you can right click on a page in Chrome, then click Inspect. Click on the Network tab, then check the box to Disable cache. You can then close out of Developer Tools.

Which HTTP prevents the browser from caching the page?

The Cache-Control header This header prevents all caching of a particular Web resource when the no-cache value is specified by an HTTP 1.1 server. Pages that are kept out of the cache aren't accessible until the browser can recontact the Web server. So, servers should use the Cache-Control header sparingly.

How does browser caching affect web design?

Caching is an incredibly useful feature that works by temporarily storing data closer to the user. By distributing shared page elements such as Javascript, CSS, and images this way, a website can attain a host of benefits – all of which positively impact the underlying business.

What is caching in web application?

In computing, a cache is a high-speed data storage layer which stores a subset of data, typically transient in nature, so that future requests for that data are served up faster than is possible by accessing the data's primary storage location.


1 Answers

Append somethign to the URL as parameter, e.g. myresource.css?version=1. The file will be servered correctly, that's a trick to force reloading the cache. You only need to generate the html page dynamically.

like image 120
ewernli Avatar answered Oct 31 '22 21:10

ewernli