Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should web-browsers allow to clear(expire) cache programmatically?

Currently browsers have incomplete caching implementation. It only allows to set expiration or keep immediate expiration. Important 3rd option to expire cache programmatically is missing. Without that 3rd option developers cannot deploy new version of code efficiently and reliably.

If they use 2nd option it is inefficient if they have framework of many small files. Combining many small files into one is not efficient because any small change will cause whole framework to be deployed instead of one single file.

If they use 1st option updates will not get to user until cache expiration which creates compatibility problems between server side code and client side code and potentially between different parts of client side code. Setting expiration requires prediction of future deployment, which is inconvenient and will disallow quick bug fixes.

When people ask about that problem, some suggest to use version numbers or other temporary ids to trick browser cache by loading unique URLs. The problem with it is that it puts unnecessary overhead on network and local file system to load and store unnecessary old versions and tons of unique URLs. It almost defeats the purpose of caching by URL. The right solution is to allow programmer of a web site to clean cache of files that came only from that web site. That way list of updated files could be requested and cache of newer files would be cleaned to allow browser to load fresh versions.

Proper caching mechanism is simple and powerful pattern that could boost all web client-side development to new levels, I only wonder why browser producers did not implement it yet.

like image 292
alpav Avatar asked Oct 23 '09 19:10

alpav


People also ask

Do browsers cache HTML files?

The browser will retrieve the HTML page from the web server but consult its cache for the static assets (JavaScript, CSS, images). We can see the difference cache makes when we refresh the Wikipedia page: The data transferred went down to 928 bytes — that's 0.3% the size of the initial page load.

How do I clear my JavaScript browser cache?

1 Right-click on the Screen. 2 Click on Inspect. This will open dev tools. 3 Then right click on the Refresh like icon and then click on Empty Cache and Hard Reload for clearing all cache and hard reload for loading fresh content along with static content like CSS, js, images, etc.

How do I force a browser to not cache?

But you can bypass the cache and force a complete refresh by using some simple hotkeys: Windows and Linux browsers: CTRL + F5. Apple Safari: SHIFT + Reload toolbar button. Chrome and Firefox for Mac: CMD + SHIFT + R.


1 Answers

Hehe, well, as far as us developers are concerned, of course!

On the other hand, cache is there to facilitate the user's experience in terms of responsiveness. It is our responsibility to work-around all these nuisances and protect the user in a shell of ignorance and all-is-wellness.

like image 198
Nikolaos Avatar answered Oct 05 '22 02:10

Nikolaos