What is the Expires HTTP Header?

HTTP Expires Header is a header that provides the date and time for specifying the limit for the response’s content staleness. This header can be set by either server or client, depending on who sends it first. It can also be sent in case of no other headers are specified.

This type of request/response specifies how long (in seconds) until cached copies become invalidated. It includes an “Expires” field with a timestamp that indicates when this cache should expire. Expires HTTP Header should be in a date format according to RFC 1123.  HTTP traditionally requires an Expires field value of no more than a year into the future. Although extended freshness lifetimes are permitted through presently acceptable values, extremely large values have been demonstrated to lead to problems, so caches will often deactivate the response way sooner than that. The HTTP Expires Header is a feature of the HTTP protocol which includes the date and time for specifying the limit for response content’s staleness. The expires field specifies how long (in seconds) until cached copies become invalidated. HTTP traditionally requires an Expires field value of no more than a year into the future. Although extended freshness lifetimes are permitted through presently acceptable values, extremely large values have been demonstrated to lead to problems, so caches will often deactivate the response.

HTTP Expires Header will be ignored if cache-control HTTP header is used with max-age or s-max-age directive. This article is to help you know what HTTP Expires Header is and how it works.

What is the Syntax of HTTP Expires Header?

To use HTTP Expires Header, “<http-date>” should be used after the “Expires” header. A correct syntax example for the expires header can be found below.

Expires: <http-date>

What are the Directives for HTTP Expires Header?

An HTTP timestamp according to the RFC 1123 format can be used as a directive for the HTTP Expires Header. An example of the HTTP Expires can be found below.

Expires: Wed, 21 Oct 2015 07:28:00 GMT

What files can Expires HTTP Header be used for?

Expires HTTP Header can be used for the files below.

  • Favicon/icon
  • JavaScript
  • CSS
  • PDF
  • Shockwave-flash
  • JPG, JPEG, GIF, and PNG

What are the Related RFC Documents for HTTP Expires Header?

The related RFC Document for HTTP Expires Header is RFC 7234. RFC 7234 defines HTTP Expires as below.

The Expires header field indicates when the response for the data collection is considered “stale,” as explained in Section 4.2. The Expires field does not imply that data storage and use will cease at, before, or after that time. An invalid date format, such as the value “0”, MUST be interpreted as an expired time.

An expiration time must not fall into the Cache-Control field of a request if it includes a max-age directive. For the same reason, a shared cache recipient MUST disregard the Expires field if the response includes the s-max-age directive (Section 5.2.2.9).

Unless its value represents a fixed time in the past (always expired) or it identifies a resource managed by a reliable clock, origin servers without clocks may NOT generate an Expires field.

HTTP has historically been restricted to Expires field values no older than one year in the future. However, extremely large values have been observed to cause problems (clock overflows because of 32 bits for time values), and many caching systems evict responses much sooner than that.

RFC 7234

Which Browsers Support Expires HTTP Header?

Below is a list of browsers that support HTTP Expires headers:

  • Opera
  • Google Chrome
  • Internet Explorer
  • Firefox
  • Safari

You can see an image that shows cross-browser compatibility of Expires HTTP Header below.

Cross-Browser Compatibility of Expires HTTP Header
Cross-Browser Compatibility of Expires is more than 60.3% for global web browser users.

How to Check Expires HTTP Header for a Response?

To check the HTTP Expires header for a response, simply right-click on it and select “View Page Info.” Underneath the browser’s name will be an entry called “Expiration Date”. To check the Expires HTTP Header with Chrome, open DevTools by pressing “F12” and go to the “Network” tab. Click on a request, and you’ll see an entry for Expires in the HTTP Headers panel at the bottom of the screen. Below, you can see an image that shows how to check Expires HTTP Header for a response via the Google Chrome browser.

Chrome DevTools Expires HTTP Header
Chrome DevTools HTTP Expires Header checking example.

To check the Expires HTTP Header with Firefox, you should open Firefox Developer Tools by pressing “F12” and going to the “Network” section. Click on response, and you’ll see an entry for Expires in the HTTP Headers panel at the bottom of the screen. Below, you can see an image that shows how to check Expires HTTP Header for a response via the Firefox web browser.

HTTP Expires Header checking example.
Firefox Developer Tools Expires HTTP Header checking example.

How to Add Expired HTTP Header to Websites?

To add the Expires HTTP Header to a website’s resources’ response, there are different methodologies according to the infrastructure of the server. In PHP, to add Expires HTTP Header, a client should use the “header()” function. To add an expired HTTP header into “.htacess” files, the “IfModule mod_expires.c” method should be used.

To learn how to add an HTTP Expires Header to the .htacess files and WordPress, you can read the related guidelines.

What are the Other Related HTTP Headers for Expires?

Expires HTTP Header is directly related to the HTTP Cache System, thus any other HTTP Caching-related HTTP Header is related to the Expires. HTTP Expires similar and related HTTP Headers can be found below.

  1. Cache-control
  2. Etag
  3. Last-modified
  4. If-None-Matched

Last Thoughts on Expires HTTP Header and Holistic SEO

The HTTP Expires Header is an important response and request header for the HTTP Cache System. HTTP Cache System is important for SEO, thus HTTP Expires Header relates to the SEO and User Experience. To consume less bandwidth from the server, serve the web pages faster, and help Search Engine Crawlers crawl a web page faster with fewer requests from the server. Expires HTTP Header is useful. Saying which resource has changed or stale to the requestor will help to perform a better web page loading experience.

The article’s conclusion is that HTTP Expires Header is important for SEO and User Experience. It also gives information about what this header is, how it helps with crawling a web page faster, and how the article will be updated in the future to include new events and information.

Our HTTP Expires Header guideline and tutorial will be updated in the light of new events and information over time.

Koray Tuğberk GÜBÜR
Latest posts by Koray Tuğberk GÜBÜR (see all)

Leave a Comment

What is the Expires HTTP Header?

by Koray Tuğberk GÜBÜR time to read: 4 min
0