+1 650 382 2225, +374 60 464 064
info@aparg.com
Facebook
Twitter
LinkedIn
YouTube
  • HOME
  • PRODUCTS
    • Aparg SmartSocial
    • Aparg SmartAd
    • Aparg HandyGIF
    • Aparg Watermark and Resize
    • Aparg Slider
  • PORTFOLIO
  • SERVICES
    • All Services
    • Hosting
  • NEWS
  • BLOG
  • CONTACTS

Optimizing WordPress – Browser Cache

July 24, 2016Tips & TricksAparg
WordPress - Browser Cache

How to speed up WordPress?

WordPress is the most used CMS nowadays. Although it's well optimized out of the box we can make it even better. There are multiple ways to speed up your WordPress blog. In this article we will talk about leveraging browser caching via .htaccess. Leveraging browser caching is also very important for SEO. Even if you have great content google will give higher page rank to websites with lower load time.

What is Browser Cache?

All modern browser has browser cache. Browser cache allows to load previously loaded resources from the local disk if they are not expired. All browsers has some default expiration values based on the resource mime type. Unfortunately these values can't work great for all websites. So knowing your website resources you can give the best instruction to client browser and as result get lowest load time.

How to leverage browser caching?

To leverage browser caching your server must be properly configured. For this you need mod_expires to be enabled on your Apache server. Most hosting providers are enabling it by default. If module is disabled you can ask your hosting provider to enable it.

There are two methods to get the result via plugin or manually. If you want to use plugin there are several WordPress plugins that are leveraging browser caching but we recommend W3 Total Cache. This is one of the most powerful caching plugins. It also has a bunch of other caching features but the one we need is browser caching. If you use caching plugins take into consideration that they are caching pages too. So if you have some automatically updated content users will be served with cached copy. So when choosing plugins be sure that they are compatible with caching plugins. Good example of such plugin is Aparg SmartAd. It is WordPress advertisement plugin and it has Anti-Cache feature. This allows you to load advertisements after the page was loaded and automatically change ads even with caching plugins enabled.

If you like to use some other WordPress cache plugin(e.g. WP Super Cache) that doesn't support browser caching settings you can do this manually. To do this  create .htaccess file in your blog root directory or if it already exists just modify it. You can set expiration period by resource mime type. It's recommended to give long expiration period to resources like images, video/audio and pdf. As for script resources it's better to give shorter expiration period. You can play with different expiration values to find configurations that best fit to your WordPress blog. Based on our experience we will post configurations that are suitable for most websites and get good results in Google PageSpeed test.

<IfModule mod_expires.c>
ExpiresActive On
# Uncomment to apply to resources that are not listed
#ExpiresDefault "access plus 1 month"

ExpiresByType text/css "access plus 1 week"
ExpiresByType text/javascript "access plus 1 week"
ExpiresByType application/javascript "access plus 1 week"
ExpiresByType application/x-javascript "access plus 1 week"

ExpiresByType image/x-icon "access plus 1 month"
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"
ExpiresByType image/svg+xml "access plus 1 month"

ExpiresByType application/x-font "access plus 1 month"
ExpiresByType application/x-font-opentype "access plus 1 month"
ExpiresByType application/x-font-otf "access plus 1 month"
ExpiresByType application/x-font-truetype "access plus 1 month"
ExpiresByType application/x-font-ttf "access plus 1 month"
ExpiresByType application/x-font-woff "access plus 1 month"

ExpiresByType application/pdf "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"

ExpiresByType video/ogg "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"
ExpiresByType video/mpeg "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/quicktime "access plus 1 month"
ExpiresByType video/x-ms-wmv "access plus 1 month"
ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType audio/x-wav "access plus 1 month"
ExpiresByType audio/mpeg "access plus 1 month"
</IfModule>

Tags: cache, optimization, plugin, wordpress
Next post Optimizing WordPress – Output Compression

6 comments. Leave new

Sergio
November 30, 2017 10:52 pm

Hello i have a wordpress site with WP Super Cache. I tried to copy the lines of code exactly as you share and i get a 500 internal server error. Any tips? what im doing wrong.
Regard from Argentina, Sergio

Reply
Aparg
December 1, 2017 1:00 pm

This configurations are general and fits to most servers. Your current problem is because of your server configurations. You can disable them part by part to understand which part is causing the error and change your server configurations to make it work.

Reply
Lyn
January 16, 2018 5:31 am

Issues come from those stupid quotes which aren’t regular ones. Just change them.

Reply
Aparg
January 18, 2018 6:35 am

Thanks Lyn, our theme was changing quotes, we have already fixed it.

Reply
Yves
April 20, 2018 12:33 pm

What does uncomment mean?

Reply
Aparg
April 20, 2018 12:54 pm

If you uncomment next line (ExpiresDefault “access plus 1 month””) all resources that are not listed above will have 1 month expiration date.

Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • WordPress (32)
    • Tips & Tricks (2)

Recent Posts

  • Complete guide for social sharing secrets
  • How to grow the number of social page’s followers with content locking
  • Best way to embed social network widgets to WordPress website
  • How to create attractive cover photos for social networks
  • Benefits of social sharing plugins

Tags

ad ads adsence affiliate android aparg api app audience banner bannersnack bike cache chrome extension cloud codecanyon compress cpanel developer envato eya16 hosting hr ios marketing media money optimization performance phonegap php plugin resize slider smartad smartsocial social networks stats team tools tv url shortener velopark watermark wordpress

Find us

We are active in majority of social networks. Follow us to get latest news about our updates, new products and events which you will like for sure.


Facebook
Twitter
LinkedIn
YouTube

Recent Posts

  • Complete guide for social sharing secrets April 14, 2018
  • How to grow the number of social page’s followers with content locking December 6, 2017
  • Best way to embed social network widgets to WordPress website November 6, 2017

Search in site

31/3 K. Ulnetsi, Yerevan(0037), Armenia

info@aparg.com

+1 650 382 2225, +374 60 464 064

HomeCareersAbout UsContacts
© Aparg Group, LLC