Add expires headers to WordPress

Trying to speed up your WordPress website? You could try to add expires headers into your WordPress .htaccess file to help with this.

Add expires headers to .htaccess file

To add expires headers into your WordPress .htaccess file without a plugin, follow the steps below:

  1. FTP into your WordPress website’s server.
  2. Open your .htaccess file, located in the root of your WordPress installation.
  3. Copy and paste in the code from below.
  4. Save and re-upload accordingly.
<IfModule mod_expires.c>
ExpiresActive On 
ExpiresDefault "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 year"
</IfModule>

Note, you can also edit your .htaccess file without using an FTP if you have Yoast SEO installed.

Using a plugin to add expires headers

Using the WP Fastest Cache plugin, you’re able to instantly add the expires headers into your .htaccess file without any coding necessary.