0

I have built a portal using Django web framework for internal company use.

The problem is every time I incorporate some changes, the users have to do ctrl + shift + R to be able to view changes.

Is there any way I can automate this process?

1 Answers1

0

Yes, you can. Browser only stores the cache if server tells to do so. And you can tell this by passing headers while giving response.

Cache-control header is responsible for this.

To turn of the caching :

Cache-Control: no-cache, no-store, must-revalidate

Check on this link for more information about - Cache-Control

This url is worth to read.

If you have different cache policy then you can also divide your page in multiple parts by identifying which part you want to reload from cache and with each request you can specify different headers.

Ujjaval Moradiya
  • 222
  • 1
  • 12
  • I dont want to disable cache control completely. Just for the pages on which I have incorporated changes, I want to drain cache for those. – aastha agrrawal Mar 27 '17 at 07:09
  • Answer is modified, see the link. If you are sending this header for some request(s) only, then it will be apply to that request(s) only (not for the whole). If you want to cache only some part of the page then send that part with another request and specify headers. Just read the link so many things written there. – Ujjaval Moradiya Mar 27 '17 at 11:20
  • I can manually do it segment wise every time I incorporate changes. How can i automate the process? – aastha agrrawal Mar 28 '17 at 11:04
  • First read that 2 urls. You can specify versions. So assume styles.1.css and you are caching this. So after updating that css just change the name 2 styles.2.css. And you don't need to press ctrl + shift + R. There are also header options available. You need to check that only. – Ujjaval Moradiya Mar 29 '17 at 08:21