Optimize WordPress Browser Cache by .htaccess

To Optimize WordPress Browser Cache by .htaccess we only need some minutes to do. It will help us very much in wordpress speed and save a lot of server resource. Think about just one logo image file what visitor will load it 10 times in 10 pageviews but now it only load from server one time because of the .htaccess optimization. Other than that, it load very fast.

 

In this article, we only focus to Apache webserver what is the most popular web server, if you manage nginx server or other webserver then I believe your server skill is good enough to optimize browser cache. Now let ‘s go with the Optimize WordPress Browser Cache.

1. Where is .htaccess file location?

It ‘s funny question but hope it ‘s helpful for some people. The .htaccess file is the base directory of wordpress directory. If you don’t see it, let ‘s create a new one. If you are using windows, when you create it by notepad, you have to write the name “.htaccess” to have the right name is .htaccess or window will not accept this type of name.

2. Gzip Compression

The coe below will show us how to compress file before return to browser what is activated when server support Google page speed module for apache. So that let ‘s install it if it is missing or choose the good hosting to support it.

3. Browser cache header and cache control

Add more code below to your .htaccess file

 

If you understand .htaccess code, you will see max-age directive is not necessary for Cache-Control header because it’s already set by the mod_expires module.

See! You are done, it ‘s quite simple. Enjoy the code and if you have any question, don’t hesitate to contact us.

Thanks!

CDN by MaxCDN