Pingdom测速中"Leverage browser caching"含义及低分优化咨询
Hey there! Let’s start by breaking down what that frustrating low score means, then walk through simple fixes to get it sorted for your site.
What Does "Leverage Browser Caching" Even Mean?
When a visitor comes to your site, their browser downloads all the static resources (like theme CSS/JS files, images, fonts) to load the page. Browser caching lets the browser store these files locally on the visitor’s device. If the cache is set up correctly, next time they visit, the browser uses the local copies instead of re-downloading everything from your server—this speeds up load times, cuts down on server traffic, and makes your site feel snappier.
Pingdom’s low score (2/10 here) is telling you that some of your static resources (like your theme files) have a too-short expiration period. That means the browser thinks those files "expire" quickly, so it re-downloads them way more often than necessary.
How to Fix This for Your WordPress Site
You’ve got a few straightforward options, depending on how comfortable you are with tech stuff:
1. Use a Caching Plugin (Easiest Option)
Most WordPress caching plugins handle browser caching automatically with just a few clicks. Popular choices include:
- WP Rocket: Head to
Settings → WP Rocket → Browser Cache, then set the expiration time for static files to at least 7 days (30 days is even better—Pingdom will love that). - W3 Total Cache: Look for the "Browser Cache" section in the plugin settings, enable it, and adjust the cache expiry times for CSS, JS, images, etc., to 7+ days.
- LiteSpeed Cache: Find the "Cache" tab, then "Browser Cache"—set the static resource expiry to your desired length (7 days minimum).
After setting this up, clear your site’s cache and re-run the Pingdom test. You should see a big jump in that score.
2. Manually Edit Your .htaccess File (For Tech-Savvy Users)
If you prefer not to use a plugin, you can add caching rules directly to your site’s .htaccess file (located in your WordPress root directory). First, make a backup of the file (just in case!), then add this code:
# Enable Browser Caching <IfModule mod_expires.c> ExpiresActive On # Images - Cache for 30 days ExpiresByType image/jpg "access plus 30 days" ExpiresByType image/jpeg "access plus 30 days" ExpiresByType image/gif "access plus 30 days" ExpiresByType image/png "access plus 30 days" ExpiresByType image/svg+xml "access plus 30 days" # CSS & JavaScript - Cache for 30 days ExpiresByType text/css "access plus 30 days" ExpiresByType application/javascript "access plus 30 days" # Fonts - Cache for 30 days ExpiresByType application/font-woff "access plus 30 days" ExpiresByType application/font-woff2 "access plus 30 days" </IfModule>
This sets a 30-day expiration for all common static resources—way more than Pingdom’s minimum requirement of a week. Save the file, clear any existing cache, and re-test.
3. Check Your Hosting Control Panel
Some web hosts (like SiteGround, Bluehost, or DreamHost) include built-in caching tools in their control panels. Look for options like "Browser Cache" or "Static File Caching"—you can usually adjust the expiration time there without touching plugins or code.
Quick Pro Tip
If you ever update your theme files, CSS, or JS, make sure to "bust" the cache so visitors get the new version instead of the old cached one. You can do this by adding a version number to the file name (e.g., style.v2.css instead of style.css) or using your caching plugin’s "clear cache" button.
内容的提问来源于stack exchange,提问作者Quoc Phu Le




