Divi WordPress Theme

Topic: How to enable leverage browser caching  (Read 1619 times)

Offline WebhostingTalk

  • Junior Guru
  • *****
  • Premium Member
  • Posts: 54
  • iTrader: +2/-0
    • View Profile
How to enable leverage browser caching
« on: April 28, 2015, 04:47:21 PM »
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
VPS Hosting - AccuWebHosting

Offline Kailash

  • Web Hosting Master
  • *****
  • Administrator
  • Posts: 604
  • iTrader: +153/-0
    • View Profile
Re: How to enable leverage browser caching
« Reply #1 on: April 28, 2015, 04:52:31 PM »
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

Offline neckozenica

  • Junior Guru
  • **
  • Posts: 54
  • iTrader: +0/-0
  • VpsWebServer Managed Windows VPS
    • View Profile
Re: How to enable leverage browser caching
« Reply #2 on: November 15, 2017, 03:59:18 AM »
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.

Offline onliveserver

  • New Member
  • *
  • Posts: 26
  • iTrader: +0/-0
    • View Profile
Re: How to enable leverage browser caching
« Reply #3 on: November 17, 2017, 01:26:01 PM »
Hello,

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

Offline neckozenica

  • Junior Guru
  • **
  • Posts: 54
  • iTrader: +0/-0
  • VpsWebServer Managed Windows VPS
    • View Profile
Re: How to enable leverage browser caching
« Reply #4 on: November 27, 2017, 06:22:21 PM »
hi,

To enable it, add those lines to 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 application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##

The .htaccess file can be modified via FTP, or the File Manager in cPanel.

When you leverage browser caching, your webpage files will get stored in the browser cache. Your pages will load much faster for repeat visitors and so will other pages that share those same resources.
Divi WordPress Theme
Tags: