K
K
koicom2017-07-12 14:36:24
Browsers
koicom, 2017-07-12 14:36:24

How to force browser to refresh files in cache storage?

The problem is this. All browsers cache static. This is good, but when the static file is updated, they continue to use the files from the cache. Because of this, during development, you have to constantly clear the cache. How do you fix things like this? I'm going to put the site into production, but I'm afraid that if I make changes to the interface, no one will see them until they clear the cache. What do you advise? I am using Python/Django. In production - nginx.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2017-07-12
@Stalker_RED

The most impenetrable way:

<link rel="stylesheet" type="text/css" href="my.css?ver=42">

The version number can be updated automatically based on the date the file was modified. If you use some kind of build system - in most cases this is included in the config or plugin.
And of course, for caching there are settings and parameters that are passed in the headers.
The first decent guide I came across for "http cache headers guide":
https://www.mnot.net/cache_docs/#CACHE-CONTROL

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question