I have a problem.

I write the site and constantly add new elements and there is a need for HardRestart, that is, a reboot that removes the cache (Shift + F5), and I know how and what to do to see the update result, but the user doesn’t and It should not, but on the smartphones generally keep quiet.

So, how to fix this, please tell me.

HTML version is 5, PHP is 7.

  • one
    Specify the required caching parameters in the HTTP headers Cache-Control and Expires - andreymal
  • @andreymal, can you give an example of where exactly to write? In htaccess or php? - Nikita Sarychev
  • It is up to you to decide where you want to write. The main thing that the browser received these headers - andreymal

2 answers 2

Most browsers do not cache HTML content, they cache mainly js , css and others. To prevent this.
For HTML you can give in the headers

 Cache-Control: no-cache 

For media content js, css, img, fonts more difficult, browsers can ignore header headers, it is better to change the URL when changing content, add for example a version. for example

 /media/static.01.js /media/style.css?v=01 

Content changed, version changed

 /media/static.02.js /media/style.css?v=02 

    There is no one solution for this problem. Because My self-written engine - I made it so that all .css files are loaded into one big style tag. That's all.