# How do I leverage browser caching?

**URL:** <https://forums.realmacsoftware.com/t/how-do-i-leverage-browser-caching/18393>\
**Category:** RapidWeaver Classic\
**Created:** [February 2, 2018, 5:54pm UTC](https://forums.realmacsoftware.com/t/how-do-i-leverage-browser-caching/18393 "2018-02-02T17:54:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steve407](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Steve407](https://forums.realmacsoftware.com/u/Steve407)\
**Post date:** [February 2, 2018, 5:54pm UTC](https://forums.realmacsoftware.com/t/how-do-i-leverage-browser-caching/18393/1 "2018-02-02T17:54:28Z")

</div>

So I’m at the point where the site I run for my company is pretty much good to go as far as I know. I went to test how my page runs because I notice it is a little slow loading the first time a machine loads it. I went in an compressed all my images and made them smaller. Here are my results now.

 ![32%20PM](https://europe1.discourse-cdn.com/flex005/uploads/realmacsoftware1/original/2X/2/273806a085ea373cb64773938e9f9d5445940808.png)

The only thing that seems to be missing apparently is to Leverage browser caching. I have searched around this forum and the only thing I’ve found on this topic is to get a [Cloudflare.com](http://Cloudflare.com) account. If that’s the only way to fix this then I will have to do it, but I figure there is a way I can do it myself.  
Site is www.liquidconsulting.se  
I use all the latest versions of rapidweaver, stacks, and foundry.

Anyone have any help on how to fix this, or anything else you see wrong with my site.

---

<div class="post-metadata">

**Author:** ![teefers](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/teefers/32/8173_2.png) [@teefers](https://forums.realmacsoftware.com/u/teefers)\
**Post date:** [February 2, 2018, 6:24pm UTC](https://forums.realmacsoftware.com/t/how-do-i-leverage-browser-caching/18393/2 "2018-02-02T18:24:15Z")

</div>

You can do it without CloudFlare, although CloudFlare does make it very easy.  
It depends on the Host on how the best way to do this would be. What you would want to do is add an expiry date to the HTTP header that is being served.  
If your running Apache as the web server you can use the .htaccess file to cache specific file types for specific periods of time with [Apache Module mod\_expires](http://mod_expires). Alternately, you can use [mod\_headers](http://httpd.apache.org/docs/2.2/mod/mod_headers.html) to customize the response header.

A sample .htaccess file using mode\_expires:

```
# BEGIN Expire headers  
<ifModule mod_expires.c>  
        ExpiresActive On  
        ExpiresDefault "access plus 5 seconds"  
        ExpiresByType image/x-icon "access plus 2592000 seconds"  
        ExpiresByType image/jpeg "access plus 2592000 seconds"  
        ExpiresByType image/png "access plus 2592000 seconds"  
        ExpiresByType image/gif "access plus 2592000 seconds"  
        ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"  
        ExpiresByType text/css "access plus 604800 seconds"  
        ExpiresByType text/javascript "access plus 216000 seconds"  
        ExpiresByType application/javascript "access plus 216000 seconds"  
        ExpiresByType application/x-javascript "access plus 216000 seconds"  
        ExpiresByType text/html "access plus 600 seconds"  
        ExpiresByType application/xhtml+xml "access plus 600 seconds"  
</ifModule>  
# END Expire headers  

```

Sample .htaccess file using mod\_heades:

```
# BEGIN Caching
<ifModule mod_headers.c>
<filesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>
<filesMatch "\\.(css)$">
Header set Cache-Control "max-age=604800, public"
</filesMatch>
<filesMatch "\\.(js)$">
Header set Cache-Control "max-age=216000, private"
</filesMatch>
<filesMatch "\\.(xml|txt)$">
Header set Cache-Control "max-age=216000, public, must-revalidate"
</filesMatch>
<filesMatch "\\.(html|htm|php)$">
Header set Cache-Control "max-age=1, private, must-revalidate"
</filesMatch>
</ifModule>
# END Caching

```

Some hosting companies restrict .htaccess files so it would be best to check their knowledge base.

CloudFlare makes this very easy, and provide a good number of other benefits, even on the free account.

---

<div class="post-metadata">

**Author:** ![Steve407](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Steve407](https://forums.realmacsoftware.com/u/Steve407)\
**Post date:** [February 5, 2018, 2:43pm UTC](https://forums.realmacsoftware.com/t/how-do-i-leverage-browser-caching/18393/3 "2018-02-05T14:43:30Z")

</div>

Appreciate the help. I will give CloudFlare a shot first I guess. I use [Godaddy.com](http://Godaddy.com) and Im pretty sure I have access to the .htaccess file if all else fails.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/system/32/25301_2.png) [@system](https://forums.realmacsoftware.com/u/system)\
**Post date:** [February 11, 2018, 2:43pm UTC](https://forums.realmacsoftware.com/t/how-do-i-leverage-browser-caching/18393/4 "2018-02-11T14:43:53Z")

</div>

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.
