Learn how to fix leverage browser caching for Apache servers to improve website loading speed, enhance user experience, and boost SEO performance with this step-by-step guide.
You ran a speed test, and it flagged “Leverage browser caching.” It sounds scary. It isn’t. On an Apache server it’s a few lines in one file.
Here’s what caching actually does. The first time someone visits, their browser downloads your images, CSS, and JavaScript. Caching tells the browser to keep those files for a while, so the next visit pulls them from disk instead of your server. Fewer requests, faster repeat loads.
Step 1: Open your .htaccess file
It lives in the root directory of your site. Get to it with an FTP client or the cPanel file manager. Back it up before you touch it.
Step 2: Add the caching rules
Paste this in and save.
<?php
# BEGIN Fix Leverage Browser Caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/gif "access 1 year"
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType image/x-icon "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/javascript "access 1 month"
ExpiresByType text/html "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/pdf "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresDefault "access 1 month"
</IfModule>
# END Fix Leverage Browser CachingThis is Apache’s mod_expires module. ExpiresByType sets how long the browser holds each file type before it checks for a fresh copy. Images sit for a year; CSS, JS, and HTML for a month. Tune those numbers to your own needs. If you’d rather send Cache-Control headers instead, that’s the mod_headers module’s job, but for most sites mod_expires is enough.
Step 3: Test it
Reload the site and make sure nothing broke. Then re-run GTmetrix or PageSpeed Insights and confirm the warning is gone.
One honest note
“Leverage browser caching” was the old GTmetrix and PageSpeed label. Current PageSpeed calls the same thing “Serve static assets with an efficient cache policy,” so don’t be thrown if the wording looks different than an old tutorial.
And keep your expectations grounded. Caching only helps returning visitors, since a first-time visitor has nothing cached yet. It also does nothing for third-party scripts you don’t host, like analytics or ad tags. Those live on someone else’s server, and their cache headers, not yours. This fix cleans up the assets you actually control, which is the part that counts.


