Expires headers tell the browser to whether to serve cached versions of a webpage by defining the expiry time. It helps to –
- Reduce server load
- Reduce requests
- Increase page load speed
What are expires headers
Expires header tells the browser whether they should request to download the same file from the server or grab it from the cache data from the browser.
Its main purpose is to reduce the HTTP request on the server and prevent the same file from being downloaded continuously.
When a user visits a website, the browser requests the server to download all the required files of the webpage. The browser sends all the data to the browser, including HTML, CSS, JS, and Images files. After displaying all the files, the browser saves those files in users’ devices as cache data.
When that user visits that page again, the browser does not request the server to download all those files back. And instead of downloading, it already shows the saved files as cache data in the browser.
This reduces the request on the server, thus reducing the load on the server.
How does expires headers work?
The function of the expire header is simple. They tell the browser how long they have to store the webpage’s files as cache data, and when to request the server to download the new files.
You can specify how long the files will save in the browser. It does not improve load time for the first time but reduces the load time of next time.
How to Add Expires Headers
Here are two methods of add Expire header to website. The first method is for WordPress user with a plugin and the second method is for all types of website.
Add Expires Headers in WordPress
This is a very easy method to add Expires header. Just install the ‘Far Future Expiry Header‘ plugin to WordPress and activate this. How you do this? Follow these steps-
- Go to WordPress dashboard
- Click on Add New in the plugin section
- Search Far Future Expiry Header and install
- Install and activate the plugin
- Go to the FarFutureExpiry option in the Setting option.
- Click on ‘Enable Far Future Expiration’.
- Enter 30 days in the number of days option
Now save the settings and clear all the cache.
Configuring Apache to serve the Expires Header (General Method)
In this method, we need to insert a code in the htaccess file. Remember that before you edit the htaccess file, you have to back-up this.
Access your website via FTP. Find the htaccess file and open it. In the htaccess file, add this following code and save it.
You can modify the expires time by changing the time in the above-given code, but the 30-days is the minimum value of it(recommended: access plus 1 year).
YOU MAY READ: 5 Useful Blogging Tools for Writing and SEO
If you like this tutorial “How to Add Expires Headers” than don’t forget to share your views in comment.