How to manage caching? On the one hand, I need that information not be cached, otherwise users will not see new messages, for this I do:

1) in the response headers from the server I issue:

Quote

Cache-Control: no-transform Pragma: no-cache Expires: Thu, 19 Nov 1981 08:52:00 GMT 

2) in the HTML code I specify:

Quote

 <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <META HTTP-EQUIV="Expires" CONTENT="-1"> 

But it turns out that not everything should not be cached, something that is desirable not to re-download. From the largest it is Java scripts and styles.

    2 answers 2

    Java scripts and styles are cached by the browser on their own. In the simplest version, create a cached_pages daddy - keep your cached pages in it. As soon as you refresh the page yourself, immediately after the update, delete its cached file from the cached_pages folder. As soon as a user visits the page, check if it is in the cached_pages folder, if yes, load it from there, if not, download it from the database (then, after loading, you can immediately place it in cached_pages and all subsequent files will be taken from the cache) . This is the most trivial example.

    • looked at developers.google.com/pagespeed it gave me this result - Use the browser cache: jquery-ui-1.8.16.custom.css and style.css (no expiration date is specified). here and i mess around Your version is very difficult to implement, by and large it is necessary to rewrite the entire engine ... there is no simpler option? - YarNik
    • one
      Do you generate styles and scripts on the fly? or do they just lie on your disk? - chernomyrdin
    • one
      most likely generates :) ahahahahahahaha ... damn amazed! - Artem
    • I solved a similar task of creating a controller for public files which, depending on the settings, told the browser to cache this or that file or not, it was quite convenient. @yarnik - if you don’t need to do it now, sooner or later it will have to be done; D - Zowie
    • chernomyrdin, no, of course. Goblin did not guess. AlexWindHope, I did not understand something about what you can learn more? - YarNik

    I wrote a caching system on the CMS, faced a similar problem, solved the problem of the emergence of new posts and comments very simply, adding a new post or comment cleared the cache, and the system immediately cached the page again.

    • What is the implementation scheme? - YarNik