Add Expires Headers: Everything That You Need to Know

Add Expires headers instruct the website whether to request a certain file from the server or to get it from the browser’s cache. The main point of add Expires Headers is to minimize not just the burden of downloads from the server, but also the number of HTTP requests for the server.

When you visit a website, your browser is in control of connecting with the webserver to download all of the necessary files. The files are then compiled to produce the web page. As online pages grow more graphically and content-rich, more files are transmitted between your system and the webserver.

In the past, you might have had an HTML file and a few photos to serve for your website, but many current websites may have 50+ files to transmit every page. The files alone can cause a significant increase in demand, but for each file, a request must be created, and even if the requests are only fractions of a second long, they can quickly pile up.

How does add Expires Headers work?

The workings of add expires Headers are quite straightforward. They inform the browser how long to keep a file in the cache so that subsequent page views and visits do not require the file to be downloaded again.

You are correct in assuming that Expires Headers do not enhance page performance for a first-time visitor since this visitor must download all of the assets for the first time. The use of add Expires Headers aids in the reduction of load times for returning visitors.

Expires headers can be placed on particular files or even file types. When the browser visits the website, it may see when the specified file types were last downloaded. If you haven’t visited the site in a while, it will download the most recent version from the web server and display them from the cache.

The aim is to establish late expiry periods for goods on your website that don’t change (logo, colors, etc). For items that change often, set short expiry durations.

What is the significance of this add Expires Headers

Expires Headers are useful for reducing HTTP requests and therefore the time it takes the server to interact with the browser. It also enables your users to reuse browser cache files, reducing the number of items they must download. It speeds up the loading of your site (after the initial request) and allows your server to handle more requests at once.

What Role Do Expiration Headers Play In-Browser Caching?

According to the regulations in the expiry headers, the browser cache saves resources. When a browser loads a website, these rules govern how the resources are used. So, if a resource’s age hasn’t expired, it will be loaded from the browser cache. If not, your computer will request it from the server once more.

What happens, though, when a computer requests a site for the first time?

In this instance, the whole site’s resources are downloaded straight from the server.

The browser will check its cache for non-expired resources after the second time and use them to save bandwidth and time.

The data is then transmitted through HTTP headers from the server to the browser. HTTP headers are used to convey additional information between your computer and the server.

Cache-Control is another essential idea that allows all of this to happen.

You may create browser-caching policies that function on both the server and client-side with Cache-Control.

The expiration time provided in the HTTP header is done via Cache-Control, Caching-Control, in summary, is a superior approach to implement browser cache since it bypasses browser-based cache.

Add Expires Headers to WordPress

  • Manually Add Expires Headers
  • Apache Server

The .htaccess file is one of the simplest ways to add expired headers to a WordPress site running on an Apache server. You can use cPanel to get to it.

To begin, go onto your cPanel account. The File Manager option may be found there. After that, go to the File Manager and choose the “public Html” folder. Once you’ve entered the folder, look for the .htaccess file. Whether you still can’t see it, check to see if the hidden files are set to “display.” Open the file by right-clicking it and selecting “edit.” Now you must save the file and add the following code to it.

<IfModule mod_expires.c>
  ExpiresActive On
  # Images
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/gif "access plus 1 year"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType image/webp "access plus 1 year"
  ExpiresByType image/svg+xml "access plus 1 year"
  ExpiresByType image/x-icon "access plus 1 year"
  # Video
  ExpiresByType video/mp4 "access plus 1 year"
  ExpiresByType video/mpeg "access plus 1 year"
  # 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 1 month"
  ExpiresByType application/x-shockwave-flash "access plus 1 month"
  • Using a Plugin to Add Expires Headers

Adding expires headers manually takes some technical knowledge. If you don’t have the technical know-how or are in a rush to activate browser caching, you may utilize plugins instead.

  • Using Hummingbird plugin

The first step is to navigate to the dashboard of your WordPress site. From there, go to “Plugins” >> “Add New.”

Then, in the upper right corner, put “Hummingbird” into the search box. After that, look for the plugin. To install it, click “Install Now.”

After you’ve activated the plugin, it’ll appear in the WordPress dashboard menu. Select “Dashboard” and then “Caching” after clicking on it.

When you arrive, you will be presented with four alternatives. To continue, click on browser caching.

The status will be displayed at the top. You can also use Hummingbird to modify your browser cache if you scroll down. You’ll find a variety of configuration choices here. You have the option of using Apache, NGINX, IIS, or Cloudflare as your server.

After that, you may specify an expiry time for all file types or specific ones. Finally, you may use the manual method to manually add expired headers. The code is generated manually based on your selections.

After you’ve set everything up, click “Activate” to enable browser caching with expired headers.

Also Read: ERR_SSL


Add Expired headers are beneficial to page loading performance. Even if it won’t make a significant difference in your site’s performance, the method is sure to improve the user experience. For this, you’ll need to add expires header in the appropriate place; if you don’t, your site will eventually slow down.