Web Hosting Forum - A Web Hosting community for Webmasters


Divi WordPress Theme

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

0 Members and 1 Guest are viewing this topic.

Offline WebhostingTalk

  • Premium Member
  • Junior Guru
  • *****
  • Posts: 50
  • 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

  • Administrator
  • Web Hosting Master
  • *****
  • Posts: 601
  • 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

  • New Member
  • *
  • Posts: 25
  • iTrader: +0/-0
  • VpsWebServer Managed Windows VPS
    • View Profile
    • Leading provider of fully managed Hyper-V Windows VPS
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

  • Newbie
  • *
  • Posts: 5
  • 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

  • New Member
  • *
  • Posts: 25
  • iTrader: +0/-0
  • VpsWebServer Managed Windows VPS
    • View Profile
    • Leading provider of fully managed Hyper-V Windows VPS
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:
 

Related Topics

  Subject / Started by Replies Last post
3 Replies
17568 Views
Last post November 25, 2009, 07:43:49 PM
by kvchosting
Browser

Started by Steve Google

16 Replies
3204 Views
Last post September 12, 2015, 03:41:15 AM
by Thechipper
7 Replies
2753 Views
Last post January 25, 2017, 09:53:02 AM
by Thechipper
2 Replies
837 Views
Last post August 19, 2017, 05:20:38 PM
by AmarInfotech
0 Replies
138 Views
Last post August 28, 2017, 04:22:36 PM
by jees123