• Welcome to Web Hosting Community Forum for Webmasters - Web hosting Forum.
 

Recommended Providers

Fully Managed WordPress Hosting
lc_banner_leadgen_3
Fully Managed WordPress Hosting

WordPress Theme

Divi WordPress Theme
WPZOOM

Forum Membership

Forum Membership

How to enable leverage browser caching

Started by WebhostingTalk, April 28, 2015, 04:47:21 PM

WebhostingTalk

Hi,

I have a shared hosting account on cPanel server. I am currently optimizing my website to speed up the loading speed. when I test my website from Google PageSpeed, it says to enable leverage browser caching. Can someone help me to enable leverage browser caching?

Thanks!

WebhostingTalk

Kailash

Most web hosts support module to enable cache expiry (browser caching) for static contents, you can refer our article on Leverage browser caching to enable caching for your static contents.

- Kailash

neckozenica

For most people, the way to enable caching is to add some code to a file called .htaccess on your web host/server.

This means going to the file manager (or wherever you go to add or upload files) on your webhost.

The .htaccess file controls many important things for your site. If you are not familiar with the .htaccess file, please read my working with .htaccess article to get some know how before changing it.

Browser caching for .htaccess
The code below tells browsers what to cache and how long to "remember" it. It should be added to the top of your .htaccess file.

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

Save the .htaccess file and then refresh your webpage.

onliveserver

Hello,

  you can put the file in public_html directory so i will take all effect for browser cache.
.........................................................................................
##

kumkum

You can easily enable browser cache by adding below code in .htaccess file.

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 year"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 year"
ExpiresByType audio/x-wav "access plus 1 month"
ExpiresByType audio/mpeg "access plus 1 month"
ExpiresByType video/mpeg "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 year"
ExpiresByType video/quicktime "access plus 1 month"
ExpiresByType video/x-ms-wmv "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresByType application/x-font-woff "access plus 1 year"
ExpiresDefault "access 1 month"
</IfModule>

You can add this code in your configuration file. To find your .htaccess file you can check steps here.

Akshay_M

Simplest: Using WordPress Dashboard
Open Dashboard of your WordPress website and then add new plugin page, here: Dashboard > Plugins > Add New.
Now search for 'Leverage Browser Caching'.
Click 'Install Now'
Activate the plugin on the Plugin dashboard.