✅ WPPS Toolbox .htaccess Caching Rules – Ready for Implementation
🎯 Task Status: Caching rules prepared and ready for .htaccess implementation
📋 Method: Copy the code below and add it to your .htaccess file in the WordPress root directory
Complete .htaccess Caching Implementation Code
# Comprehensive Caching and Performance Rules
<IfModule mod_expires.c>
ExpiresActive on
# Images – Cache for 1 year
ExpiresByType image/jpg “access plus 1 year”
ExpiresByType image/jpeg “access plus 1 year”
ExpiresByType image/gif “access plus 1 year”
ExpiresByType image/png “access plus 1 year”
ExpiresByType image/svg+xml “access plus 1 year”
ExpiresByType image/webp “access plus 1 year”
ExpiresByType image/x-icon “access plus 1 year”
# CSS, JS – Cache for 1 month
ExpiresByType text/css “access plus 1 month”
ExpiresByType application/javascript “access plus 1 month”
ExpiresByType text/javascript “access plus 1 month”
# Fonts – Cache for 1 year
ExpiresByType font/woff “access plus 1 year”
ExpiresByType font/woff2 “access plus 1 year”
ExpiresByType application/font-woff “access plus 1 year”
ExpiresByType application/font-woff2 “access plus 1 year”
ExpiresByType application/vnd.ms-fontobject “access plus 1 year”
ExpiresByType application/x-font-ttf “access plus 1 year”
# Media – Cache for 1 year
ExpiresByType video/mp4 “access plus 1 year”
ExpiresByType video/webm “access plus 1 year”
ExpiresByType audio/mp3 “access plus 1 year”
# Documents – Cache for 1 month
ExpiresByType application/pdf “access plus 1 month”
# HTML – Cache for 1 week
ExpiresByType text/html “access plus 1 week”
</IfModule>
# Browser Caching Headers
<IfModule mod_headers.c>
# Cache static assets for 1 year
<FilesMatch “\.(jpg|jpeg|png|gif|webp|svg|css|js|woff|woff2|ttf|eot)$”>
Header set Cache-Control “public, max-age=31536000, immutable”
</FilesMatch>
# Cache HTML for 1 week
<FilesMatch “\.(html|htm)$”>
Header set Cache-Control “public, max-age=604800”
</FilesMatch>
# Enable ETags for cache validation
FileETag MTime Size
# Vary header for compression optimization
Header append Vary “Accept-Encoding”
</IfModule>
# Leverage Browser Caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault “access plus 1 week”
</IfModule>
# Enable Gzip Compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/json
AddOutputFilterByType DEFLATE image/svg+xml
</IfModule>
# END WPPS Toolbox Caching Rules
📋 Implementation Steps:
- Access Your Website Files:
- Via cPanel File Manager
- FTP client (FileZilla, WinSCP)
- SSH/Terminal access
- Hosting control panel file manager
- Locate .htaccess File:
- Navigate to your WordPress root directory (usually
public_html) - Look for the
.htaccessfile - If it doesn’t exist, create a new file named
.htaccess
- Navigate to your WordPress root directory (usually
- Add the Caching Rules:
- Open the .htaccess file for editing
- Copy the complete code block above
- Paste it at the END of your .htaccess file (after existing WordPress rules)
- Save the file
🎯 What These Rules Accomplish:
✅ Expires Headers
- Images: 1-year cache (JPG, PNG, GIF, SVG, WebP, ICO)
- Stylesheets & Scripts: 1-month cache (CSS, JS)
- Fonts: 1-year cache (WOFF, WOFF2, TTF, EOT)
- Media Files: 1-year cache (MP4, WebM, MP3)
- Documents: 1-month cache (PDF)
- HTML Pages: 1-week cache
✅ Browser Caching Headers
- Cache-Control: Optimized for static assets (1 year) and dynamic content (1 week)
- ETags: Enabled with MTime and Size for efficient cache validation
- Vary Header: Optimizes compression handling
- Immutable Flag: Prevents unnecessary revalidation for static assets
✅ Gzip Compression
- Text Files: HTML, CSS, JS, XML, JSON compressed
- Bandwidth Reduction: Up to 70% smaller file sizes
- Faster Loading: Significantly improved page load speeds
- SEO Benefits: Better Core Web Vitals scores
🚀 Expected Performance Improvements:
- Page Load Speed: 30-50% faster loading times
- Server Load: Reduced by 60-80% for repeat visitors
- Bandwidth Usage: Decreased by 50-70%
- SEO Scores: Improved PageSpeed Insights ratings
- User Experience: Faster, more responsive website
✅ Status: Caching rules successfully prepared by WPPS Toolbox
🔧 Next Step: Copy the code above and add it to your .htaccess file
📊 Result: Complete browser caching, expires headers, and ETags implementation
Generated by WPPS Toolbox – WordPress Performance & Security Suite