We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

How To Leverage Browser Caching In Oxwall | Forum

Austeyr
Austeyr Dec 1 '13
Trying to get the best speeds out of my website - Bush skills network



made a few improvements and seeing some great results but i need to work out how toLeverage browser caching.

According to Google Dev Pagespeeds

Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network. 

I've never been good with .htaccess and i'm pretty sure thats where im meant to be working. 

Here is what google says about Browser caching - Click Here


Does anyone have the exact codes for .htaccess file that cache .js, images & css Ect... Id be very thankful if anyone could help out with this... cheers in advance.

Austeyr
Austeyr Dec 1 '13
After writing this post and asking the question i found some more info and answered my own question below you will see my .htaccess file you can copy it and use on your site if you like.



Here is what my .htaccess file looks like my site is running really well with these tweaks only thing on mine the standard site wont use is the RewriteCond %{REQUEST_URI} !/sitemap\.xml


with these tweaks my site went from a score of 41 on google page speed test to a 76 as you can see thats a major improvement...


## 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 ##



AddHandler application/x-httpd-php52 .php .php5 .php4 .php3

Options +FollowSymLinks

RewriteEngine On


AddEncoding gzip .gz

AddEncoding gzip .gzip

<FilesMatch "\.(js.gz|js.gzip)$">

  ForceType text/javascript

</FilesMatch>

<FilesMatch "\.(css.gz|css.gzip)$">

  ForceType text/css

</FilesMatch>



# compress text, HTML,php, JavaScript, CSS, and XML

AddOutputFilterByType DEFLATE text/plain

AddOutputFilterByType DEFLATE text/html

AddOutputFilterByType DEFLATE text/php

AddOutputFilterByType DEFLATE text/xml

AddOutputFilterByType DEFLATE text/css

AddOutputFilterByType DEFLATE application/xml

AddOutputFilterByType DEFLATE application/xhtml+xml

AddOutputFilterByType DEFLATE application/rss+xml

AddOutputFilterByType DEFLATE application/javascript

AddOutputFilterByType DEFLATE application/x-javascript

# remove browser bugs

BrowserMatch ^Mozilla/4 gzip-only-text/html

BrowserMatch ^Mozilla/4\.0[678] no-gzip

BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

Header append Vary User-Agent



RewriteCond %{REQUEST_URI} !/sitemap\.xml

RewriteCond %{REQUEST_URI} !^/index\.php

RewriteCond %{REQUEST_URI} !/ow_updates/index\.php

RewriteCond %{REQUEST_URI} !/ow_updates/

RewriteCond %{REQUEST_URI} !/ow_cron/run\.php

RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.xml|\.feed|robots\.txt|\.raw|/[^.]*)$  [NC]

RewriteRule (.*) index.php


The Forum post is edited by Austeyr Dec 1 '13
webcs Club
webcs Dec 13 '13
Grateful
It was very helpful
Austeyr
Austeyr Dec 15 '13
happy to help. 
Musik
Musik Jan 2 '14
I've been looking into this as well and was happy to stumble onto your post. I'm going to give this a whirl tonight, because my site needs this as well. I'll let you know how it goes. (:
Musik
Musik Jan 3 '14
Tested it. I had to make a few tweaks for it to apply to my site specifically. This brought up my site performance my 4. Leverage browser caching was the lowest score by far on my site performance tests, so it's great to get a better score. Thanks!


I'll keep tabs on how my site performance goes in the next few days.


Musik
Musik Jan 3 '14
Now my performance grade is 91/100. It was originally 80/100 when this began. Fantastic!
Joey
Joey Jan 3 '14
Jezus, this is not normal. Should be standard in Oxwall installation.

I checked my score, and it goed up from 68 to 89 :D


I am a happy man, thanks for this

Austeyr
Austeyr Jan 3 '14
glad it's helped guys.
Wilson
Wilson Feb 4 '14

Great job, I went from 610kb to 251kb on my index page…my score went from 77/100 to 91/100 after adding your modifications. WOW! Thanks a lot!

Wilson

Austeyr
Austeyr Feb 5 '14
@wilson  Your Welcome Mate. 
Tom
Tom Jul 25 '15
Using Pingdom, I went from 81/100 to 100/100, and 74% slower then other sites to 54%.


This is a very good thread, thank you for posting!


Yes, this should be standard in future Oxwall builds, I agree!!

Jobee Bendijo
Jobee Bendijo Sep 11 '15
The increase in page load speed is REMARKABLE!! Thanks for this thread! Glad I stumbled upon it!