Expires Headers: How Does It Work and Is It Important for SEO?
The speed of loading a page on a site became a ranking factor for Google back in 2010. Since 2017, the loading speed of a mobile page has also become a factor (see the Mobile Search article for how to improve it). In addition, this criterion affects UX and user behavior. According to Google research, the likelihood that a user will leave the site after waiting for 5 seconds is three times higher than when waiting for 3 seconds. Therefore, for website developers and SEO professionals, the issue of increasing download speed is very important.
Among the ways to do this is various caching, in particular by adding the expires header. Let’s see when this function is effective, how to apply it, and how it promotes SEO.
What is Expires Header?
The expires header is an HTTP header that indicates whether it is possible to obtain information on request from the browser cache or if you need to access the server since the page option in the cache is already outdated. This header contains the date and time until the page is available in the browser cache. Headings come in two different forms as follows:
- ExpiresDefault: By default, the specified time interval is applied to all site resources. It should be used with special attention and caution. We will write about this in more detail further in the article.
- ExpiresByType: applies the time interval in relation to the resource for which it is registered.
ExpiresDefault “access plus 10 month”
ExpiresDefault “access plus 1 year”
ExpiresByType image/jpg “access plus 3 month 2 weeks”
ExpiresByType text/html “access plus 1 year 2 month 10 days”
ExpiresByType text/css “access plus 2 month 3 weeks”
Thus, you can precisely set the time down to days and even hours during which the page will be stored in the browser cache.
How Cache and Expires Header Affect Page Loading Speed
A response to a user request from the cache takes less time than a response from the server. These processes look like this:
As you can see, the path to cache information is simpler and shorter. The way the cache affects the speed of the site can be seen in the following examples. The news site doesn’t use a cache, ao its page opening speed is slow:
Amazon uses caching partially. Its average speed is as follows:
On this site you can see a high level of caching usage, as well as high speed:
Of course, many factors affect the speed of pages opening, including:
- Volume and weight of content, size, and the number of photos used
- Technical features of the site, features of the CMS platform
- The degree of complexity of design and layout
- The speed and quality of the server
- Using Accelerated Mobile Pages technology and others. Read more in the What You Need to Know About Accelerated Mobile Pages article
At the same time, the use of caching can affect the download speed of individual pages, so it is sometimes advisable to use this technology. Let’s consider when it is worth it to add expires headers and for which pages will be a good way to speed up and stay in the users’ field of vision.
When, How, and for What Types of Pages Should You Use Expires Header?
The use of an expires header is reasonable for pages and content elements that are updated either periodically or will be changed in the near future. The benefits of headers come from the fact that with their help it is possible to keep content in the browser’s cache. It is also helpful tat it leaves its changes visible to the user and removes obsolete content from caching in time.
Image expires tags can be especially relevant since they allow you to fix the storage time in the cache of images. This may become obsolete and lose their relevance over time.
Before you add the expires header to the HTML structure, you should carefully analyze the content and understand what will change and what will remain unchanged. Read more in the article Website Content Audit. For example, long stored can be:
- Home page with carefully thought-out design, text, style, and so on
- Key structural content
- Sections with product categories on e-commerce site, more information in the Ecommerce SEO article
- Archive pages of information portals, creative blogs with articles, photos, etc.
When thinking about where and how to use the expires header, it is important to consider all the components of the content and foresee how long you plan to leave it unchanged. With extreme caution, you should approach the ExpiresDefault header, which applies the specified period to all content by default. If certain elements change at different times, it is better to register time intervals separately using the ExpiresByType syntax. With its help, dynamic and updated elements can be configured so that they will change in their own rhythm.
Pay particular attention to working with expire headers when working with e-commerce sites. It will be useful to regularly check expire headers so that the information stored in the cache matches is the current information on the site.
In the case of electronic stores, it often happens that users later return to the pages of products stored in the browser cache. In order to avoid problems with the customer service, in case the product is regularly updated, or if the product is expected to be out of stock within a month or so, it is worth mentioning in the expire headers of the corresponding pages.
Another option where you can effectively use expire headers is the event page. For example, if you have a movie festival website, its information will remain relevant for a certain time. So, you can apply expires headers for a page with tickets, a program, participants, etc., fixing the interval until it is relevant. By linking the end date for the content with the end of the festival, the pages of the site that remain in the user’s cache will be updated, being filled with fresh content.
How to Add Expires Headers?
In order to add expires headers in WordPress, you can use plugins, particularly ones developed by the same CMS – Add Expires Header.
Using it, you can easily select files of different types where expires headers will be set at a time interval for them. At the same time, the interval in the plugin is indicated in days, so it is important to carefully check the deadline in order to avoid making the mistake of the header being in place for a long time:
In order to add expires headers in WordPress without plugin, you can use the service to set headers from the Apache server. To do this, .htaccess files will be used. Access can be obtained using the cPanel or FTP tool, which you can work with using the free FileZilla service.
In general, configuration using the plugin can be faster but working manually can create more variations for the expires headers. However, when working manually, you will need to carefully check the accuracy of the specified action time, which can be especially important, especially for e-commerce sites.
Expires Headers and SEO
In summary, it is worth noting that the use of expires headers can be useful from an SEO point of view since caching makes the site faster and the appearance of relevant information in the browser will be useful for UX. At the same time, as in any work with headings, it is important to pay attention to details, not to forget about updates depending on the content, and think ahead of time about the timing by which it will be updated. All this takes time. Therefore it is advisable to use expires headers for the content where update time is really important. If the content is not dynamic, then specifying an additional HTML header is hardly worth it.