Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Don't want to clear browser cache on every time for css/js updates

I have python-django site which contains css and js files. For every time of updating/adding css or js have to clear the cache of the browser then only its reflect in browser.

Is the any specific way to do avoid every time cache clear and check?

Is there any specific settings available in django to avoid storing browser cache?

like image 668
keshavv Avatar asked Nov 21 '12 06:11

keshavv


People also ask

How do I stop JavaScript caching in Chrome?

Here's how... 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.

Is clearing your browser cache necessary?

It is a good idea to clear your browser cache because it: prevents you from using old forms. protects your personal information. helps our applications run better on your computer.

How do I force the browser to reload cached .JS CSS?

The user either has to clear the browser cookie & reload the page or else he or she has to do a hard refresh of the page by pressing Ctrl+F5.

Does CSS get cached?

When a browser caches a CSS stylesheet, what it's doing is getting that stylesheet from the server once, saving it, and then serving its own saved version of that stylesheet to the user anytime the page being loaded requests it.


1 Answers

You could just append something to the updated js/css file, like this. For example versioning "?v=1.0".

<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}_css/style.css?v=1.6">

So this way, every time the browser detects a change, it will automatically fetch the new file. Simple and clean.

like image 183
DTailor Avatar answered Nov 15 '22 04:11

DTailor