Updating cached images / css / js without renaming

I am wondering how people are updating the / css / js images regarding browser cache.

Obviously, it is useful to use mod_expires and have a future expiration date, etc. - but how can you update these files if you do not want to constantly rename the file?

Does anyone have interesting tricks with a version number that will not jeopardize the browser (or proxy), who does not want to cache the file, but will still guarantee that the user sees the new version if it is updated?

+3
source share
3 answers

The general way to do this is to create a random number and add it as a GET / POST variable. For instance:

http://example.com/myfile.html?r=189818273

....

0

, . FireBUG . 304, , 200, . , , .

0

I would add a query string parameter with a timestamp of the last file modification:

http://example.com/script.js?v=123456

Alternatively, you can define a global variable in your application and use it as a timestamp. When you change one of the files, just increase this variable. This means that all of your resources will be invalid at the same time, but it may be a simpler solution than reading the file's timestamp.

0
source

Source: https://habr.com/ru/post/1788206/


All Articles