Need an SEO Expert? Get Your Free Strategy Session?
Skip to main content

page speed

How to fix the “Serve static assets with an efficient cache policy” warning

Est. reading time: 1 minutes

Quick Answer: How to Add Expires Headers With.

How to Add Expires Headers With .htaccess on Apache Web Server

If your web host uses the Apache web server, you can add Expires headers using the .htaccess file, which is located in the root folder of your server (the same folder that holds the wp-config.php file).

Here’s what you need to do:

  1. Connect to your server using FTP in your preferred FTP client
  2. Locate the .htaccess file in the root folder
  3. Download a backup copy of the .htaccess file to your local computer. That way, if anything goes wrong, you can reupload your backup copy to fix any potential problems.
  4. Add the code snippet below near the top of the file

## EXPIRES HEADER CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType image/svg "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES HEADER CACHING ##

While the default values should work fine for most sites, you can adjust the time periods for different file types in the code snippet according to your needs.