WebsiteHeadLogo

We are going to put here our monthly free giveaways. Stay Tuned!

0975-625-7614

J.P. Rizal St, Bayawan City, 6221 Negros Oriental

Top
leverage browser caching

#1 How to Leverage Browser Caching in WordPress via htaccess

How to Leverage Browser Caching in WordPress via htaccess? Well That is a very good question and it is very easy to do.

#1 How to leverage browser caching in WordPress via htaccess

This topic is Fix Laverage Browser Caching in .Htaccess File, well it is simple im assuming you are not using wordpress or if you are? then this is the code to update in the htaccess file. just copy it and access your hosting and file manager then go to htaccess file and click edit. Put the codes in it. but before doing it you should have a backup on your htaccess file.

How to edit the .htaccess file?

how to leverage browser caching in wordpress via .htaccess

Editing your htaccess will be really easy. If you are not a developer like me. You can simply download and install this plugin on your site. It is called Htaccess Editor.

You can also go to this link and download the plugin: Htaccess Editor – Safely Edit Htaccess File

After you installed the plugin go to your settings > WP HTACCESS EDITOR.

how to leverage browser caching in wordpress via .htaccess

After you activated the plugin you can copy the codes below and save changes. That’s just it.

Adding expires Header

# TN - START EXPIRES CACHING #
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/x-icon "access 1 year"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresDefault "access 1 month"
</IfModule>
# TN - END EXPIRES CACHING #

Adding cache control headers

You can add Cache-Control headers in Apache by adding the following to your .htaccess file. Snippets of code can be added at the top or bottom of the file (before # BEGIN WordPress or after # END WordPress).

<filesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=84600, public"
</filesMatch>

Enable Gzip Compression

Enable Gzip compression is by editing your .htaccess file.  Most shared hosts use Apache, in which you can simply add the code below to your .htaccess file. You can find your .htaccess file at the root of your WordPress site via FTP.

<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml
  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4.0[678] no-gzip
  BrowserMatch bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>

Deflating compression headers

<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml
  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>

Conclusion

Speeding your WordPress Site is always a must in boosting your SEO rankings. By adding this codes to your htaccess file you can have boost on the speed of your website.

Need more help how to leverage browser caching in wordpress via htaccess?

Checkout my article here: How to Speed up Your WordPress Site in 2019

I help businesses drive more traffic to their website. My past work involves Search Engine Optimization, doing on-page SEO, and also off-page SEO. On-page SEO Optimization On-Page SEO (WHITEHAT SEO) is one of the most critical factors for the success of your website SEO campaigns. The things that must be optimized in your post or pages are the Heading tags, Meta Text, Content, and more. For content development, I can provide you with 30 well-written blog posts. That is double-checked with Grammar errors and also plagiarized free content. You will approve the targeted keyword and title of the URL before we execute. But if you are in a hurry, We can decide that part for you.

No Comments

Post a Comment