How To Leverage Browser Caching For Your WordPress Website

Hoe To Add Expires Headers To Your WordPress Website



How To Leverage Browser Caching For Your WordPress Website


Test your site at https://gtmetrix.com first.


Analyze your site’s speed and make it faster.


GTmetrix gives you insight on how well your site loads and provides actionable recommendations on how to optimize it.


===================================


Here are a few different code snippets for Expires Headers. If you are not sure what you are doing, please refer to the video and/or contact your hosting service for help.


>> This is the one I used in the video <<


<IfModule mod_expires.c>

# Enable expirations

ExpiresActive On

# Default directive

ExpiresDefault “access plus 1 month”

# My favicon

ExpiresByType image/x-icon “access plus 1 year”

# Images

ExpiresByType image/gif “access plus 1 month”

ExpiresByType image/png “access plus 1 month”

ExpiresByType image/jpg “access plus 1 month”

ExpiresByType image/jpeg “access plus 1 month”

# CSS

ExpiresByType text/css “access plus 1 month”

# Javascript

ExpiresByType application/javascript “access plus 1 year”

</IfModule>


Here are a few other code snippets for you to compare and / or use. If not sure please stick with what was shown in the video or contact your hosting service for help.


<IfModule mod_expires.c>

ExpiresActive On

ExpiresByType image/x-icon “access 1 year”

ExpiresByType image/jpg “access 8 days”

ExpiresByType image/jpeg “access 8 days”

ExpiresByType image/gif “access 8 days”

ExpiresByType image/png “access 8 days”

ExpiresByType text/css “access 8 days”

ExpiresByType application/pdf “access 8 days”

ExpiresByType text/x-javascript “access 8 days”

ExpiresByType application/x-shockwave-flash “access 8 days”

ExpiresDefault “access 2 days”

</IfModule>


OR…


<IfModule mod_expires.c>


ExpiresActive on

ExpiresDefault “access plus 1 month”


# CSS

ExpiresByType text/css “access plus 1 year”


# Data interchange

ExpiresByType application/json “access plus 0 seconds”

ExpiresByType application/xml “access plus 0 seconds”

ExpiresByType text/xml “access plus 0 seconds”


# Favicon (cannot be renamed!)

ExpiresByType image/x-icon “access plus 1 week”


# HTML components (HTCs)

ExpiresByType text/x-component “access plus 1 month”


# HTML

ExpiresByType text/html “access plus 0 seconds”


# JavaScript

ExpiresByType application/javascript “access plus 1 year”


# Manifest files

ExpiresByType application/x-web-app-manifest+json “access plus 0 seconds”

ExpiresByType text/cache-manifest “access plus 0 seconds”


# Media

ExpiresByType audio/ogg “access plus 1 month”

ExpiresByType image/gif “access plus 1 month”

ExpiresByType image/jpeg “access plus 1 month”

ExpiresByType image/png “access plus 1 month”

ExpiresByType video/mp4 “access plus 1 month”

ExpiresByType video/ogg “access plus 1 month”

ExpiresByType video/webm “access plus 1 month”


# Web feeds

ExpiresByType application/atom+xml “access plus 1 hour”

ExpiresByType application/rss+xml “access plus 1 hour”


# Web fonts

ExpiresByType application/font-woff “access plus 1 month”

ExpiresByType application/vnd.ms-fontobject “access plus 1 month”

ExpiresByType application/x-font-ttf “access plus 1 month”

ExpiresByType font/opentype “access plus 1 month”

ExpiresByType image/svg+xml “access plus 1 month”


</IfModule>


OR…


<IfModule mod_expires.c>


# Enable expirations

ExpiresActive On


# Default directive

ExpiresDefault “access plus 1 month”


# My favicon

ExpiresByType image/x-icon “access plus 1 year”


# Images

ExpiresByType image/gif “access plus 1 month”

ExpiresByType image/png “access plus 1 month”

ExpiresByType image/jpg “access plus 1 month”

ExpiresByType image/jpeg “access plus 1 month”


# CSS

ExpiresByType text/css “access 1 month”


# Javascript

ExpiresByType application/javascript “access plus 1 year”


</IfModule>


 


 


======================================


If you have ANY questions or need any help, please feel free to reach out by leaving a comment below!


ALSO, if you enjoyed this tutorial, please drop a THUMBS UP and a COMMENT letting me know!


======================================


 


 


 







how to use wordpress guide





How To Leverage Browser Caching For Your WordPress Website#WordPressPerformanceTutorial

Comments