Last-Modified header
Last-Modified is an HTTP response header containing the date a resource last changed (RFC 7232 format). On subsequent requests, clients send `If-Modified-Since` with that date; the server returns 304 Not Modified if nothing has changed. Googlebot honors this and saves crawl capacity on stable URLs.
Long definition
The header format is fixed: Last-Modified: Wed, 21 Oct 2024 07:28:00 GMT. RFC 7231 mandates GMT and the IMF-fixdate format; deviations break parsers.
The conditional flow mirrors ETag's:
- First request: server sends
200 OKwithLast-Modified: <date>. - Client caches the response and stores the date.
- Subsequent request: client sends
If-Modified-Since: <date>. - Server compares: file unchanged →
304 Not Modified(empty body). File changed →200 OKwith new content and new Last-Modified.
For SEO, the impact is on crawl efficiency. Googlebot uses Last-Modified two ways.
Reducing crawl spend. A 304 response is a fraction of the bandwidth of a 200. On large sites with many static or rarely-changed pages, this lets Google crawl more URLs within the same capacity ceiling.
Re-crawl scheduling. Googlebot factors the Last-Modified date into how often it returns to a URL. A page that hasn't changed in two years gets crawled less often than one updated weekly. This is also why XML sitemaps use the <lastmod> element — same signal at the sitemap level.
Common pitfalls:
- Lying about freshness. Some CMSes update
Last-Modifiedto "now" on every request to discourage caching. Result: Googlebot recrawls everything, wastes budget, and trusts the signal less. - CMS template changes invalidating Last-Modified for the whole site. A header/footer edit shouldn't bump every page's modification date. Many platforms get this wrong.
- Resolution mismatch. Last-Modified has 1-second resolution. For high-traffic pages updated multiple times per second, ETag is the correct choice. Most pages don't have this problem.
Last-Modified vs ETag:
- Last-Modified is simpler to implement (a
stat()call) and the date carries semantic meaning. - ETag is more precise and doesn't depend on filesystem timestamps.
- They coexist; clients prefer ETag when both are present, falling back to Last-Modified.
Common misconceptions
- "Updating Last-Modified forces a re-crawl." It signals freshness, but Googlebot decides scheduling. Lying about freshness teaches Google to ignore the signal.
- "Last-Modified must match
<lastmod>in the sitemap." They should be roughly consistent — a 30-day delta on a page where the sitemap claims yesterday's update suggests one of the two is broken. - "Static sites don't need it." They benefit the most. Static-site generators set Last-Modified naturally; ensure your CDN or web server passes it through.
Continue exploring