vBulletin 4 optimized .htaccess
This .htaccess will optimize your server and increase your page load scores (higher score is a good thing). This will set the images to expire after a certain amount of time as well as numerous other optimization tricks for your server. These set the expires headers for images, and set some cache-control headers as well. Place this at the very top of your .htaccess file, remember to back up and test first.
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType text/html "access plus 1 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 216000 seconds"
ExpiresByType application/x-javascript "access plus 216000 seconds"
</ifModule>
<ifModule mod_headers.c>
<filesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=259200, public"
</filesMatch>
<filesMatch "\\.(css)$">
Header set Cache-Control "max-age=604800, public"
</filesMatch>
<filesMatch "\\.(js)$">
Header set Cache-Control "max-age=21600, private"
</filesMatch>
<filesMatch "\\.(xml|txt)$">
Header set Cache-Control "max-age=21600, public, must-revalidate"
</filesMatch>
<filesMatch "\\.(html|htm|php)$">
Header set Cache-Control "max-age=1, private, must-revalidate"
</filesMatch>
</ifModule>
<ifModule mod_headers.c>
Header unset ETag
</ifModule>
FileETag None
<ifModule mod_headers.c>
Header unset Last-Modified
</ifModule>
about 8 months ago
Nice bit of code David. Have you installed vb4 yet ?
about 8 months ago
Worked like a charm according to firebug! Thanks a million for this
about 8 months ago
Thanks david, I installed it on my VB4 site after a recommendation from someone over at vbulletin.org.
about 8 months ago
Do you recommend somthing like this for vB3 installations as well.
What’s the difference in vB4 htaccess compared to vB3?
Bookmarked, thanks
about 8 months ago
Yes, you can even use this in previous vBulletin versions, or on just about any web site that makes use of images actually to get a performance improvement.
about 7 months ago
worked like a charm.One issue i encountered.For those that is on a windows server you have to change the module name from to this , after adding the above info i was getting a random Apache fault module php5ts.dll errors and this happened after i added the script.But after changing the module name everything is working fine…
thanks
about 7 months ago
ok it didnt take the info properly form this ifModule mod_expires.c to this ifModule expires_module
about 4 months ago
Would you happen to have this in a code that IIS7 would read? Maybe a web.config file? I’d greatly appreciate this, thanks!
about 3 months ago
Hello, is this the .htaccess for the root of server or vbulletin folder?
Thanks
about 3 months ago
How can I exclude some adserver codes/addresses?
Because *.gif banners caching doesn’t really good for me…
about 3 months ago
I have no idea what any of that code means, but it sure made a difference on my small forums. Excellent work, sir.
But I do have one question… how would incorporate it up to not allow hotlinking of images except for from one certain directory?
about 2 months ago
Amazing!!!! Thank you very much
about 1 month ago
Amazing code! Thanks for the share dude.
about 1 month ago
I used this and i got a higher score and some issues resolved,but it was not completely resolved,page speed still tells me that I need to make some of the cache more than 7 days.
Is their any harm in setting it higher?.