Support

Find answers, guides, and tutorials to supercharge your content delivery.

If-Modified-Since HTTP Header

Updated on October 4, 2018
If-Modified-Since HTTP Header

What does the If-Modified-Since header do?

The If-Modified-Since HTTP header indicates the time for which a browser first downloaded a resource from the server. This helps determine whether or not the resource has changed since the last time it was accessed. If the HTTP status of a particular resource is 304 Not Modified, this means that the file has not changed and there is no need to download it again. Having this ability allows both the website owner and visitor to conserve resources as the file does not have to be retrieved each time.

Why does it matter?

Googlebot crawls billions of pages resulting in a large amount of resources used to index each page on the Internet. If a particular page has not been modified since the last time Google crawled it, there is no need for Google to download that file again, thus it can move on to the next. This helps improve efficiency and save bandwidth at the same time.

However, do not mistake this as an incentive to save bandwidth by purposely not updating or adding new content to your site. Yes, Googlebot is going to use some bandwidth to crawl your site but in most cases this is fairly minimal. Adding new content, making your site faster, getting more links to your site, etc. are all great ways to move up in the SERPs. The more Googlebot crawls your site, the better it will be for your website's SEO. The status 304 code simply helps improve the efficiency when a bot crawls your site.

How does it work?

A conditional GET request is at the basis of how a If-Modified-Since header works. When a conditional request is made for a particular resource, the client provides the server with the Last-Modified date of its cached copy by using the If-Modified-Since header.

The server then determines based on these headers if the client's cached copy is the most recent version of this file. If so, the server returns an HTTP status 304 code, letting the client know it can reuse its cached copy.

If the the client does not have a cached copy, like if it is the first time visiting the resource, the resource must be downloaded from the origin server, resulting in an HTTP code 200. Similarly this code will also be returned for requests that have an outdated version of a resource stored in cache thus requiring the latest resource to be fetched from the server.

Example

KeyCDN's WordPress Cache Enabler plugin also makes use of the If-Modified-Since HTTP header. It does so to help browsers determine if the content of a particular page has changed since the creation of the static HTML file.

As can be seen upon initial load of the KeyCDN support page, an HTTP status code of 200 is shown for the HTML document. In this case there was no cached copy in the browser cache, therefore the HTML file was retrieved from the origin server.

Upon refresh, the browser realizes that the file has already been downloaded thus the browser sends the If-Modified-Since header back to the server. As can be seen by the image below, the server evaluated it's copy and the browser's cached copy and determined that there have been no changes since the last download, resulting in a 304 Not Modified status.

Summary

Knowing what the If-Modified-Since HTTP header does, helps give you a better understanding of what efficiency measures are being taken to make the web faster. Having the ability to use a cached copy of a resource can without a doubt save time for the user and makes the process of crawling webpages more efficient for search engines.

Supercharge your content delivery 🚀

Try KeyCDN with a free 14 day trial, no credit card required.

Get started
KeyCDN uses cookies to make its website easier to use. Learn more