As a WordPress website owner, adding expires header can help speed up your website. It works in two ways: reduces the number of HTTP requests sent to the server and reduces the number of files that need to be downloaded as a web cache.
This article will explain two simple methods in adding expires header in your WordPress website; with and without a plugin.
Caching plugins are the best choice because they let you enable browser caching and expires headers in just several simple steps. The steps below are done with W3 Total Cache.
In this option, adding expires headers to a WordPress website is done manually. Below, we have outlined the steps for Apache and Nginx servers:
ExpiresActive On
ExpiresByType text/html “access 1 month”
ExpiresByType text/css “access 1 month”
ExpiresByType text/javascript “access 1 month”
ExpiresByType text/x-javascript “access 1 month”
ExpiresByType image/jpeg “access 1 year”
ExpiresByType image/jpg “access 1 year”
ExpiresByType image/png “access 1 year”
ExpiresByType image/svg “access 1 year”
ExpiresByType image/gif “access 1 year”
ExpiresByType application/pdf “access 1 month”
ExpiresByType application/javascript “access 1 month”
ExpiresByType application/x-javascript “access 1 month”
ExpiresByType application/xhtml+xml “access 1 month”
ExpiresByType application/x-shockwave-flash “access 1 month”
ExpiresByType image/x-icon “access 1 year”
ExpiresDefault “access 4 days”
Other file types expire after different periods. Depending on your content, you may want to change the expiry date in your HTTP response header.
Other than those mentioned methods, plenty of techniques can be done to speed up your website. We have a new package that guarantees to speed up your WordPress site to load in 2-3s, with only a $79 fixed fee, done in 72h. Results guaranteed or full refund.
ExpiresActive On
ExpiresByType text/html "access 1 month"
ExpiresByType text/css "access 1 month"
ExpiresByType text/javascript "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType image/svg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/xhtml+xml "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 4 days"