I'm trying to give the browser the Last-Modified header. However, the browser remembers it only while open. One has only to close and restart the browser, and it no longer returns the If-Modified-Since header. Question: why and how to force the browser to remember Last-Modified after restarting? Probyval Chrome and Mozile.

Sketched a small code to illustrate the problem:

  if (isset ($ _ SERVER ['HTTP_IF_MODIFIED_SINCE']) or isset ($ _ ENV ['HTTP_IF_MODIFIED_SINCE']))
 {
     echo 'The server has received an “If-Modified-Since” header from the user with a value of "'. $ _ SERVER ['HTTP_IF_MODIFIED_SINCE']. '" and has confirmed it.';
 }
 else
 {
     header ('Last-Modified: Mon, Oct 18 2010 14:15:00 GMT');
     echo 'Last-Modified header was sent to user.';
 } 

That is, if you open a page with this code, and then close the browser, start it again and return to this page, the browser does not return If-Modified-Since.

PS: please do not throw slippers

  • Something like this: Для всех кешируемых ресурсов нужно обязательно указывать один заголовок из пары Expires и Cache-Control max-age, а также один заголовок из пары Last-Modified и ETag. Использовать и Expires, и Cache-Control: max-age излишне, как и указывать Last-Modified и ETag одновременно. Для всех кешируемых ресурсов нужно обязательно указывать один заголовок из пары Expires и Cache-Control max-age, а также один заголовок из пары Last-Modified и ETag. Использовать и Expires, и Cache-Control: max-age излишне, как и указывать Last-Modified и ETag одновременно. and Last-Modified – "слабый" заголовок, так как браузер применяет эвристические алгоритмы, чтобы определить, запрашивать ли элемент из кеша. - Visman
  • And why should the browser remember? And in general, the browser on the reel has this heading. At each access to this page, what heading you will put up and will be. This heading is necessary for indexing bots - Vanya Avchyan
  • Well, in general, a useful title, you can keep a heavy design on the client, and you can mark the client. - Konstantin

1 answer 1

In general, the casket just opened. Together with Last-Modified, you need to send a Cache-Control header: must-revalidate This will cause the browser to send a request each time to validate the content.