Easy way to Add Expires Header to WordPress

Easy way to Add Expiry Header to WordPressWelcome guys. I’m Mukesh. Today we are going to learn how to add Expires header to WordPress site. Here a quick and easy tutorial to add Expire header to website. So let’s see how we add Expire header in WordPress.

Before we start, we some talk about what is the importance

Importance of Expires Header

Adding Expires Headers is important to reduce HTTP requests which reduce the time it takes for the server to communicate with the browser. It also allows your users to reuse the cache files like images: jpg, gif, png, favicon/ico, javascript, CSS etc. that have been stored in the browser to reduce the number of files they need to download.

Finally, the main importance of Expires Header is to reduce the load on site and making the site faster.

Click here to know other methods of speed up WordPress 

How to Add Expires Header

Here are two methods of add Expire header to WordPress. One is adding by Plugin and other is adding by manually add code in htaccess file.

Method 1: Far Future Expiry Header Plugin

This is a very easy method to add Expire header. Just install ‘Far Future Expiry Header‘ plugin to WordPress and activate this.

How you do this? Follow this step:

  1. Go to your dashboard
  2. Click on Add New in the plugin section
  3. Search Far Future Expiry Header and click on install
  4. Activate the plugin
  5. After activate, Go to FarFutureExpiry option in Setting option.
  6. Click on ‘Enable Far Future Expiration’.
  7. Enter the value 30 in Number of Day option.
  8. Save this.

Great job, you have all done. Now, Expire Header has been added to your website.

If you down want to install any plugin then this is another method to add Expire header without a plugin.

Method 2: Add Expires Header htaccess

This is an advanced option to add Expires header to WordPress. In this method, we need to insert a code in the htaccess file. Remember that before you edit the htaccess file, you have to backup this. So let start:

Access your website via FTP. Find the htaccess file and open it. In the htaccess file, add this following code and save it.

<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On 
# Default directive
ExpiresDefault "access plus 1 month"
# My favicon
ExpiresByType image/x-icon "access plus 1 year"
# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
# CSS
ExpiresByType text/css "access plus 1 month"
# Javascript
ExpiresByType application/javascript "access plus 1 year"
</IfModule>

So these are two easy methods of adding Expire header in WordPress of our blog. If you have any problem with this, you can free to ask us in the comment section. Good bay.

YOU MAY LIKEHow to add Web Push Notification on WordPress

Add Comment