The HTML expires meta tag defines the expiry date and time of the element being viewed. This may be the web page as a whole or individual items such as images.
The expires meta tag ca be used to indicate to browsers how long to retain their copy of web page components such as images, CSS files and JavaScript files. thus improving the loading time of the page on future visits.
If your website is running a limited time event or there is a preset date when your document will no longer be valid, you should include the expires tag to indicate to search engines when to delete your webpage from their database.
As an example consider a website running a competition. After the entry date visitors should be discouraged from visiting – there will be no competition. There’s always one or two likely to visit a website page covering a special event after the event end.
The expires tag is also used to force browsers to re-cache the contents covering potential changes which have been made.
The more frequent the changes to a web page the shorter the expiry delay is to be configured.
An example is a latest news page. Or a blog page, with regular daily updates.
How to use the Expires Meta tag
Here’s an example of the expires meta tag:
<meta name=”expires” content=”01/12/2015″>
The date and time after which the document should be considered expired. An illegal EXPIRES date, e.g. “0”, is interpreted as “now”. Setting EXPIRES to 0 may thus be used to force a modification check at each visit.
Web robots may delete expired documents from a search engine, or schedule a revisit.
HTTP 1.1 (RFC 2068) specifies that all HTTP date/time stamps MUST be generated in Greenwich Mean Time (GMT) and in RFC 1123 format.
RFC 1123 format is wkday “,” SP date SP time SP “GMT”
Where..
wkday = (Mon, Tue, Wed, Thu, Fri, Sat, Sun)
date = 2DIGIT SP month SP 4DIGIT ; day month year
time = 2DIGIT “:” 2DIGIT “:” 2DIGIT ; 00:00:00 – 23:59:59
month = (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec)
Bringing this together for 9am on 28th March 2021 gives:
<meta name=”expires” content=”Sun, 28 Mar 2021 09:00:00”>
Check if there is an option to use date plus offset for example
<meta name=”expires” content=”Sun, 28 Mar 2021 09:00:00”>
htaccess
The .htaccess file located in the root of the website can be used to configure many options. It includes an entry affecting the content expiry
ExpiresDefault “access plus 1 month”
The expiry option configured will be active across the website. Different entries can be configured according to the file extension, for example:
<IfModule mod_expires.c> ExpiresActive On # Images ExpiresByType image/jpeg "access plus 3 months" ExpiresByType image/gif "access plus 3 months" ExpiresByType image/png "access plus 3 months" ExpiresByType image/webp "access plus 3 months" ExpiresByType image/svg+xml "access plus 3 months" ExpiresByType image/x-icon "access plus 3 months" # Video ExpiresByType video/mp4 "access plus 3 months" ExpiresByType video/mpeg "access plus 3 months" # CSS, JavaScript ExpiresByType text/css "access plus 1 month" ExpiresByType text/javascript "access plus 1 month" ExpiresByType application/javascript "access plus 1 month" # Others ExpiresByType application/pdf "access plus 3 months" ExpiresByType application/x-shockwave-flash "access plus 3 months" # Everything else ExpiresDefault "access 1 month" </IfModule>
If you wish to target files within a particular folder then another .htaccess file is required to be saved in that folder.
Usage of this file allows a standard set of configuration options to be developed over time. Deploying this to a website achieves consistency and ease of implementation.
Advantages/Disadvantages
Setting a general limit on the ageing of website content can help to ensure that browsers will periodically refresh their content.
A browser may be still using its cache copy of your website’s content but beyond the set expiry date the browser will once again pick up on the content afresh.
If you are using a global expiry duration and some of your images have been updated its possible that the old image version is maintained by the browser, until the expiry deadline has been reached.
Usage of the expires meta tag can also be used when changes have occurred to the website code files and imagery.
Beware leaving a fixed expiry date in place for too long. Whilst its in place the performance of your website will be downgraded for returning visitors. Maybe an old value is also an indication of a site which has become neglected.
Other Thoughts
If you are making changes to a website and the client’s browser is being particularly annoying, retaining the old content, you may wish to try setting an expiry value of zero
<meta name=”expires” content=”0″>
There are other meta options which can be used to Force Browser to Reload Cache From the Website.


