• OzzModz is no longer taking registrations. All registrations are being redirected to Snog's Site
    All addons and support is available there now.

Quick and easy way to leverage browser caching of static assets.

Max Taxable

The Wyatt Earp of Anti-Spam
Force browsers to cache static assets and also define length of caching time for them.

In your .htaccess file, insert:

HTML:
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType application/javascript A604800
ExpiresByType application/x-javascript A604800
ExpiresByType text/javascript A604800
ExpiresByType text/css A604800
ExpiresByType image/gif A604800
ExpiresByType image/x-icon A604800
ExpiresByType image/icon A604800
ExpiresByType image/jpg A604800
ExpiresByType image/jpeg A604800
ExpiresByType image/png A604800
</IfModule>
And that's it.

Works 100% of the time, every time. Makes your site load blisteringly fast, greasy and slick, due to the leveraged caching.

You're welcome.



NOTE: Does nothing at all if you're using a CDN.

Ozzy's more comprehensive caching list:
Code:
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css A2628000
    ExpiresByType text/richtext A3600
    ExpiresByType image/svg+xml A3600
    ExpiresByType text/plain A3600
    ExpiresByType text/xsd A3600
    ExpiresByType text/xsl A3600
    ExpiresByType video/asf A2628000
    ExpiresByType video/avi A2628000
    ExpiresByType image/bmp A2628000
    ExpiresByType application/java A2628000
    ExpiresByType video/divx A2628000
    ExpiresByType application/msword A2628000
    ExpiresByType application/x-msdownload A2628000
    ExpiresByType image/gif A2628000
    ExpiresByType application/x-gzip A2628000
    ExpiresByType image/x-icon A2628000
    ExpiresByType image/jpeg A2628000
    ExpiresByType application/vnd.ms-access A2628000
    ExpiresByType audio/midi A2628000
    ExpiresByType video/quicktime A2628000
    ExpiresByType audio/mpeg A2628000
    ExpiresByType video/mp4 A2628000
    ExpiresByType video/mpeg A2628000
    ExpiresByType application/javascript A2628000
    ExpiresByType application/x-javascript A2628000
    ExpiresByType application/vnd.ms-project A2628000
    ExpiresByType application/vnd.oasis.opendocument.database A2628000
    ExpiresByType application/vnd.oasis.opendocument.chart A2628000
    ExpiresByType application/vnd.oasis.opendocument.formula A2628000
    ExpiresByType application/vnd.oasis.opendocument.graphics A2628000
    ExpiresByType application/vnd.oasis.opendocument.presentation A2628000
    ExpiresByType application/vnd.oasis.opendocument.spreadsheet A2628000
    ExpiresByType application/vnd.oasis.opendocument.text A2628000
    ExpiresByType audio/ogg A2628000
    ExpiresByType application/pdf A2628000
    ExpiresByType image/png A2628000
    ExpiresByType application/vnd.ms-powerpoint A2628000
    ExpiresByType audio/x-realaudio A2628000
    ExpiresByType application/x-shockwave-flash A2628000
    ExpiresByType application/x-tar A2628000
    ExpiresByType image/tiff A2628000
    ExpiresByType audio/wav A2628000
    ExpiresByType audio/wma A2628000
    ExpiresByType application/vnd.ms-write A2628000
    ExpiresByType application/vnd.ms-excel A2628000
    ExpiresByType application/zip A2628000
</IfModule>
 
Last edited:
WOW... I am going to have to say WOW. Seems to be running very smooth.. I added that code to two site .htaccess file... went through every page I had.
The image pages used to hang a second or two.. seems to be much quicker.

Thank you.
allhail.gif
 
My site is slightly faster but not that much...i have to say that i have a lot of images on the main page.
Check it here: Windows 7 & 8 Custom Themes - MegaThemer
Wow.... Ouch you really are loaded down. 194 requests and 6.9 megabytes worth. yes, MEGAbytes. Unbelievable. Here's Meehan's analysis of your site:

WebPagetest Test Result - Dulles : [url]www.meg...r.x10.mx/forum.php - 01/29/14 23:24:55[/url]

You still get the grade F for caching static content because your CDN overrides my little trick completely. Sorry to say it is doing nothing for you.

Here's all your images, the file sizes on them might shock you - the smallest ones on your page are some of the biggest files:

WebPagetest Page Images - Dulles : [url]www.meg...r.x10.mx/forum.php - 01/29/14 23:24:55[/url]


You really and very badly, need to optimize all your images.

Just for fun, turn all hooks off in adminCP>Options>Plugin/Hook System and run a fresh test at same site with hooks off. Prepare to be shocked.
 
WOW... I am going to have to say WOW. Seems to be running very smooth.. I added that code to two site .htaccess file... went through every page I had.
The image pages used to hang a second or two.. seems to be much quicker.

Thank you.
allhail.gif
It's amazing how blazingly quick it makes your site load, annit!

Glad you like.
 
Yes i know i was completely shocked...i did those test before lol.
I really need to optimize my images some day!
 
Yes i know i was completely shocked...i did those test before lol.
I really need to optimize my images some day!
How do you sleep at night knowing your site loads 6MB on people's browsers? Most sites only load maybe 700KB :eek1:

Hope you're on a host that doesn't mind tons of unnecessary bandwith. Any of my sites would have to load 350 times to get anywhere close to 6mb.

And you're closer to 7... 6.9MB to be exact.:twitch:

Speed is what gets it on the web, friend. You have sacrificed speed for garishness and overdone luridness. Your site is a fat and over made up LuLu Roman, while the sites I mentioned in the OP are all svelte, Daisy Dukes!

More power to you friend, not trying to be insulting or mean, just trying to be helpful. I have seen a good many sites suspended or outright kicked off from their host for having half as much load bytes as you have.
 
I am not offended buddy...my hosting provider is okay with it and i don't get any complains from my members!
But i know i need to fix this asap...btw it seems that you know a lot of this stuff,do you know any good tool that compresses png's etc...?
 
I am not offended buddy...my hosting provider is okay with it and i don't get any complains from my members!
But i know i need to fix this asap...btw it seems that you know a lot of this stuff,do you know any good tool that compresses png's etc...?
Most of the ones that look small on your rendered page are really, very large files. You can re-size these with no loss in quality and greatly reduce their file size. Refer back to the link I sent where your images are defined, one by one. Not hard to see the offenders there.

Megabyte = one MILLION bytes. You are loading nearly 7 million bytes on folks browsers.

People might not complain but it hurts your SEO - google hates slow sites.
 
This is what I have been using in mine since I started the site.

Code:
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css A2628000
    ExpiresByType text/richtext A3600
    ExpiresByType image/svg+xml A3600
    ExpiresByType text/plain A3600
    ExpiresByType text/xsd A3600
    ExpiresByType text/xsl A3600
    ExpiresByType video/asf A2628000
    ExpiresByType video/avi A2628000
    ExpiresByType image/bmp A2628000
    ExpiresByType application/java A2628000
    ExpiresByType video/divx A2628000
    ExpiresByType application/msword A2628000
    ExpiresByType application/x-msdownload A2628000
    ExpiresByType image/gif A2628000
    ExpiresByType application/x-gzip A2628000
    ExpiresByType image/x-icon A2628000
    ExpiresByType image/jpeg A2628000
    ExpiresByType application/vnd.ms-access A2628000
    ExpiresByType audio/midi A2628000
    ExpiresByType video/quicktime A2628000
    ExpiresByType audio/mpeg A2628000
    ExpiresByType video/mp4 A2628000
    ExpiresByType video/mpeg A2628000
    ExpiresByType application/javascript A2628000
    ExpiresByType application/x-javascript A2628000
    ExpiresByType application/vnd.ms-project A2628000
    ExpiresByType application/vnd.oasis.opendocument.database A2628000
    ExpiresByType application/vnd.oasis.opendocument.chart A2628000
    ExpiresByType application/vnd.oasis.opendocument.formula A2628000
    ExpiresByType application/vnd.oasis.opendocument.graphics A2628000
    ExpiresByType application/vnd.oasis.opendocument.presentation A2628000
    ExpiresByType application/vnd.oasis.opendocument.spreadsheet A2628000
    ExpiresByType application/vnd.oasis.opendocument.text A2628000
    ExpiresByType audio/ogg A2628000
    ExpiresByType application/pdf A2628000
    ExpiresByType image/png A2628000
    ExpiresByType application/vnd.ms-powerpoint A2628000
    ExpiresByType audio/x-realaudio A2628000
    ExpiresByType application/x-shockwave-flash A2628000
    ExpiresByType application/x-tar A2628000
    ExpiresByType image/tiff A2628000
    ExpiresByType audio/wav A2628000
    ExpiresByType audio/wma A2628000
    ExpiresByType application/vnd.ms-write A2628000
    ExpiresByType application/vnd.ms-excel A2628000
    ExpiresByType application/zip A2628000
</IfModule>
 
That's MUCH more extensive and inclusive! Thanks!

But, what's the vnd and oasis stuff and is it relevant for all vB installations?
 
when you input this in httacess file does it matter where you put it when other things are in there like beginning or end ??

thanks for this very nice indeed if it speeds things up
 
when you input this in httacess file does it matter where you put it when other things are in there like beginning or end ??

thanks for this very nice indeed if it speeds things up
It shouldn't matter I wouldn't think, unless something else in your .htaccess is already using the ifModule_mod. And even at that I don't know that it would be a problem. I would just put it at the very top to make sure I'm not putting it in the middle of other code.

This can't do any lasting damage, if it causes issues you can simply remove it. It's safe to try.
 
Back
Top