3

What headers used in request by google bot? Must be user agent, but what else? I'm interested in cache control headers, does bot try to get fresh page, but not from cache?

The related question: Do browsers send different HTTP headers on page reload so that server side caches can be flushed?

I'm using server cache, what have option to refresh on Ctrl+F5, but don't want bot to refresh page. Code what detect Ctrl+F5 below:

function cacheHitDisplay($params)
  if ($_SERVER['HTTP_CACHE_CONTROL'] == 'no-cache') {
    // process/refresh page. ctrl-f5 pressed
    return 0;
  }
  getFromCache($params);
  exit 0
}
cacheHitDisplay(); // will show cached page and exit script
...here normal page processing, saving page to cache at end...
2
if ($_SERVER['HTTP_CACHE_CONTROL'] == 'no-cache') {

Also bear in mind that the Cache-Control HTTP request header (as with most request headers) are entirely optional, so may not be present as part of the request at all. (This line would then generate an E_NOTICE under these conditions.)

In fact, I don't believe Googlebot sends the Cache-Control header when performing it's regular website crawl (as opposed to Fetch and Render in GSC). This is from my own logs, and from those reported online. So, if you "don't want bot to refresh page" then you would seem to be correct to specifically check for "no-cache" in order to refresh your server-side cache.

The HTTP Request headers that I typically see from Googlebot are really quite minimal:

Host: www.example.com
Connection: keep-alive
Accept: text/plain,text/html,*/*
User-Agent: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
Accept-Encoding: gzip,deflate,br

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.