Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

HTTP headers | expires

  • Last Updated : 19 Nov, 2019

The HTTP Expires header is a response-type header, the fundamental way of controlling the caches present. The expire header contains the date and time which denotes the period where the object can stay alive. Once the period expires, the object becomes stale. Almost every client support expire headers. The expire headers are usually ignored if a cache-control header is present with a max-age directive. The users need not press the reload button in order to get a live object. Once the time expires the caches take control over the pages. Web servers allow clients to set the expire headers in multiple ways. The two most common ways may include:

  • Last access time: It sets the expire time-based on the final time the client accessed the object.
  • Last modification time: It denotes the last time the document was changed on the server.

Syntax:

Expires: <http-date>

Directives: The HTTP Expires header accepts a single directive mentioned above and described below:

  • <http-date>: This directive contains the date time information of the retirement.

Below example will illustrate the HTTP Expires header:

Example: In this example, the object is set with an expiry date and time. It will enable the caches to know when to get a fresh copy of the object. The users need not press the reload button in order to get a live object. Once the time expires the caches take control over the pages.

Expires: Mon,11 Nov 2019 08:36:00 GMT

To check this Expires in action go to Inspect Element -> Network check the response header for Expires like below, Expires is highlighted you can see.

Note: The time denoted in HTTP date should always hold Greenwich Meridian Time(GMT) and not local time.

Supported Browsers: The browsers are compatible with HTTP Expires header are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Safari
  • Opera
My Personal Notes arrow_drop_up
Recommended Articles
Page :