Hosting + Ai Website Builder + Free Domain (3 Month Free Credit)
Shop Today

How to Add Expires Headers To Your WordPress Website?

Let’s see what is Expires Headers and how to add expires headers to your WordPress website step-by-step.

Expires headers are the protocols or rules which is used by the web browsers to know whether to load a web page resources like images, videos etc. from the visitor’s browser cache or from the server directly.

If web page resources will be loaded from your cache, results in the reduction of server load and improved performance of your website.

In this article, we’ll show you how to add expires headers in WordPress.

  1. By adding a WordPress Plugin
  2. By adding the code manually

By adding a WordPress Plugin

  1. Login into your wordpress dashboard and go to Plugins.
How to Add Expires Headers To Your WordPress Website? 1

2. Click “Add New“, search for “W3 Total Cache” and click on Install Now button.

How to Add Expires Headers To Your WordPress Website? 2

3. Click “Activate” to activate the plugin.

How to Add Expires Headers To Your WordPress Website? 3

4. After activation of the plugin, go to Performance –> General Settings.

How to Add Expires Headers To Your WordPress Website? 4

5. Click “Accept” and click on “Skip Guide”

How to Add Expires Headers To Your WordPress Website? 5

6. In the Page Cache section, select the “Disk: Enhanced” method and “Enabled” it.
This method will reduce the response time of your website and increase the scale of your web server.

How to Add Expires Headers To Your WordPress Website? 6

7. Minify DISABLE

Minification can sometimes break your site but shrink your site’s code without losing any of its functionality, so you should employ some caution here. Keep it in “Auto” mode.

How to Add Expires Headers To Your WordPress Website? 7

8. Database cache

Caching database objects decreases the response time of your site but it’s best to skip this option for shared hosting plans but, if you are using VPS or Dedicated Servers you can enable this option.

How to Add Expires Headers To Your WordPress Website? 8

9. Object Cache

Keep it disabled for shared hosting plans as Object cache too can draw heavily on server resources.

How to Add Expires Headers To Your WordPress Website? 9

10. Browser cache

You must “Enable” this option because it tells a browser to save a copy of the page resulting in reduced server load and decrease response calls to your website.

How to Add Expires Headers To Your WordPress Website? 10

11. CDN(Content Delivery Network)- Disable

If you’re using a Content Delivery Network (CDN) from any third-party service like Cloudflare, then you don’t need to enable this one.

How to Add Expires Headers To Your WordPress Website? 11

12. Reverse Proxy – DISABLE

Reverse proxies are generally required in private hosting. Therefore, Disabled it.

How to Add Expires Headers To Your WordPress Website? 12

Leave all the other settings to default.

By adding a code manually

  1. Login to your control panel. Here I am taking DirectAdmin panel. After login, scroll down and click on “File Manager” icon.
How to Add Expires Headers To Your WordPress Website? 13

2. Navigate to the domain and double-click on it. Select your domain name(if you are having multiple domains) then double-click on the public_html folder.

How to Add Expires Headers To Your WordPress Website? 14

3. Here, you will find the .htaccess file. Right-click on this file and click Edit.

How to Add Expires Headers To Your WordPress Website? 15

4. Copy and paste the following lines of codes into 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"

</IfModule>

5. If you want, you can change the time parameters as per your own settings.

I hope this will help you in “Adding Expires Header” in WordPress.

YouStable

Power up your business website with YouStable India’s affordable unlimited web hosting services and meet your online success! YouStable is not just a brand that provides hosting services to clients. The quality of services a customer gets from us is unparalleled and our clients know it.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top