Open In App

HTTP headers | expires

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:

Syntax:



Expires: <http-date>

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

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:

Article Tags :