I
I
Igor Samokhin2012-05-29 14:04:37
Search Engine Optimization
Igor Samokhin, 2012-05-29 14:04:37

Last-modified for the search engine and blocking browser caching, how will the search engine behave?

Hello,
on the Internet I saw different non-specific opinions on this matter, please advise. My question is:

header("Cache-Control: no-cache,no-store,max-age=0,must-revalidate"); //запрет кеширования
header("Expires: " . date("r")); // ставится текущая дата и время // тоже запрет кеширования
header('Last-Modified: '. $LastModified); // ставится реальная дата когда менялся домкумент

/* full function code just in case */
$LastModified = gmdate("D, d M Y H:i:s \G\M\T", $LastModified_unix);
$IfModifiedSince = false;
if (isset($_ENV['HTTP_IF_MODIFIED_SINCE']))
       $IfModifiedSince = strtotime(substr($_ENV['HTTP_IF_MODIFIED_SINCE'], 5));  
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']))
       $IfModifiedSince = strtotime(substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 5));

header("Cache-Control: no-cache,no-store,max-age=0,must-revalidate"); // иногда используют
header("Expires: " . date("r"));
if ( $IfModifiedSince && $IfModifiedSince >= $LastModified_unix ){
      header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified');
      exit;
}
header('Last-Modified: '. $LastModified);

what I want to do:
I want search engines to cache pages - considering last modified, and browsers NOT to cache - because I wrote them no-cache, no store and set Expires - which is always the most recent
question:
search engines will NOT pay attention to Expirex and no -cache? will they only look at last modfied?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
I
Igor Samokhin, 2012-05-29
@grigor007

Damn, I just saw it, the opera still caches ...
how to make it so that search engines give Last-modified, and browsers do not pay attention to last-modofied, only track browsers?

A
AntonioK, 2012-05-29
@AntonioK

Search engines do NOT consider Last-modified, Expires and Cache-Control to determine whether or not to index a page.

W
woto, 2012-05-29
@woto

Not entirely on topic, but sorting by date still benefits.

D
Dan, 2014-06-05
@golotyuk

Try expires in past tense:
from here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question