A
A
Andrew2015-07-27 08:09:57
css
Andrew, 2015-07-27 08:09:57

Why, when updating the css file name, the old css is still loaded for the old site users on the first visit?

Why, when updating the css file name, the old css is still loaded for the old site users on the first visit?
But when you refresh the page, new css is already loaded.
Tell a newbie.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Denis Ineshin, 2015-07-27
@IonDen

The easiest thing you can do in this situation is to update the version of the file every time you change something in the code. For example, like this:
made some changes, updated the version:
etc.
This simple trick allows you to tell user browsers exactly when to overwrite a file in the cache.

N
nonlux, 2015-07-27
@nonlux

Browser cache, web server cache

P
Pavel242, 2015-07-27
@Pavel242

Caching is to blame. If you don't want to fiddle with versions after the file name, as suggested above, you can simply add the modification date. In php you can use filemtime()

<link rel="stylesheet" href="style.css?201507271028" />

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question