News:

Wondering if this will always be free?  See why free is better.

Main Menu

[Depreciated]

Started by Depreciated, August 09, 2010, 08:39:48 PM

Previous topic - Next topic

Depreciated

Link to the mod


Simple .htaccess Cache Mod v2.7
~{By PaulpBaker}~

Link to Mod | My Mods | Support Topic

Compatibility
Version independent so will work on ALL versions of SMF!

Description
Very simple 'mod' to add some basic yet very effective caching option to your .htaccess file.

(Please read the below warnings in the 'Notes' section)

Before using this mod:

Page load time: 4.04s
Total page size: 139KB

After using this mod:

Page load time: 2.80s
Total page size: 52.2KB

(See screenshots for results)

This mod is fully compatible with my other .htaccess mods: Simple .htaccess Bot Blocker Mod and Simple .htaccess Proxy Blocker Mod

Have some suggestions to make this mod better? Please let me know in the support topic.

Notes
Requires: mod_deflate, mod_expires and mod_gzip to be installed and enabled for apache.

If you get any errors after installing this you ether didn't have mod_deflate, mod_expires and mod_gzip installed/enabled but you can simply uninstall this 'mod' by removing the following code from your .htaccess file in your web root folder

#Simple .htaccess Cache Mod
[code here]
#Simple .htaccess Cache Mod


Installation
Any previous versions of this mod MUST be uninstalled BEFORE installing this version.

Install the package on the SMF Default 'Curve' Theme ONLY. Other themes will need manual edits.

Useful Links
SMF Package Parser
Manual Installation Of Mods
How Do I Modify Files?

Support
Please use the modification thread for support with this modification.
(Please don't ask me to do the edits for you)

Changelog[/color
v2.7 - 1st September 2016: Updated to make compatible with SMF 2.0.11
v2.6 - 21st October 2010: Added uninstall option
v2.5 - 19th August 2010: Added support for mod_gzip which should improve loading times
v2.0 - 17th August 2010: Total rewrite of the mod so stop it from causing problems for people who already have a .htaccess file
v1.1 - 16th August 2010: Made the code a little more sexy and added some error protection (thanks Sirius OCTeam!)
v1.0 - 8th August 2010: Initial Version

flapjack

another smart mod, however those settings will not work with all providers ;)

Depreciated

Quote from: flapjack on August 09, 2010, 08:48:04 PM
another smart mod

thank you i really appreciate the feeedback :)

Quote from: flapjack on August 09, 2010, 08:48:04 PM
those settings will not work with all providers ;)

true but that's why i gave the warning about you needing mod_deflate and mod_expires to be installed and enabled and i'd expect most to have them

flapjack

unfortunately my providers have mod_expires disabled. one of the reasons for moving towards vps

Depreciated

wow that's sucks i didn't know that but still a lot of people will get some use out of this mod as although simple it does give good results

IdanC

#5
omfg! 25% improvement in loading time! i shall name my first born after you.

almost too good to be true, is there a catch?

flapjack

Quote from: IdanC on August 10, 2010, 06:55:03 PM
omfg! 25% improvement in loading time! i shall name my first born after you.

almost to good to be true, is there a catch?
if it works - no. but as I mentioned, some providers doesn't offer this functionality

Depreciated

Quote from: IdanC on August 10, 2010, 06:55:03 PM
omfg! 25% improvement in loading time! i shall name my first born after you.

almost too good to be true, is there a catch?

sarcasm or not 25% is an amazing improvement especially on large sites

IdanC

don't let the last part fool you, i'm very appreciative of this improvement, and with almost a thousand daily visits, i'm sure my visitors are too.

Depreciated


nend

Isn't it allot safer to cache by extension instead of mime type. One of my mods uses dynamic JavaScript which will change on page load, this shouldn't be cached.

See with languages like PHP you can send out any mime type you want but the extension will always be PHP. See if you cache by mime type your leaving the browser open to cache dynamic images or scripts that shouldn't be cached.

Here is something I have in my .htaccess.
# 1 YEAR
<FilesMatch "\.(ico|pdf|flv)$">
Header set Cache-Control "max-age=29030400, public"
</FilesMatch>
# 1 WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
# 2 DAYS
<FilesMatch "\.(xml|txt|css|js)$">
Header set Cache-Control "max-age=172800, proxy-revalidate"
</FilesMatch>
# 1 MIN
<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=60, private, proxy-revalidate"
</FilesMatch>

Nirose

is this mod supposed to increase the memory load. cuz after i add the mod my Server Load gets upto 8+.



samjay

thanks for the mod pal! looks promising :)

Nao 尚

Why is the access date set to expire in one month? That's a lot isn't it? Especially for CSS and Javascript files... I suppose it means that even if these files are updated, the server will send a Not Modified header for them or something? Meaning the only way to force caching them is by adding/changing the ?suffix after the filename?
I will not make any deals with you. I've resigned. I will not be pushed, filed, stamped, indexed, briefed, debriefed or numbered.

Aeva Media rocks your life.

flapjack

CSS and JS files in SMF are already being called with suffix, so you need to worry only about additional files

www.bokupa.com

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.


What ???????????????????

divecall

@paulpBaker:

In your screenshot, on what site you was doing the measurment for the loading performance ?

thanks in advance.

IdanC

Quote from: expact on August 14, 2010, 01:22:23 AM
Internal Server Error

i got one too, freaked me out a little bit, i think it was an embedded video from youtube that didn't mix well with this mod, but i'm not sure.

meanwhile, i'm trying out nend's htaccess. working fine so far, hoping not to come across that evil 500 screen again.

Depreciated

Quote from: expact on August 14, 2010, 01:22:23 AM
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.


What ???????????????????

you should have read the description this is ONLY for servers with mod_deflate and mod_expires installed AND enabled for apache

i also gave instructions saying to delete the .htaccess file in your web root folder if you installed this without the above

Quote from: IdanC on August 14, 2010, 05:41:11 AM
Quote from: expact on August 14, 2010, 01:22:23 AM
Internal Server Error

i got one too, freaked me out a little bit, i think it was an embedded video from youtube that didn't mix well with this mod, but i'm not sure.

meanwhile, i'm trying out nend's htaccess. working fine so far, hoping not to come across that evil 500 screen again.

as above and i don't see how a youtube video caused that... :\

Quote from: divecall on August 14, 2010, 03:57:17 AM
@paulpBaker:

In your screenshot, on what site you was doing the measurment for the loading performance ?

thanks in advance.

i'm using the amazing gtmetrix.com ;)

Sirius OCTeam

#19
Hi

you should add those conditions to minimizing the internal server error crash risk for some users:
<IfModule mod_deflate.c>
#the code
</IfModule>
<IfModule mod_expires.c>
#the code
</IfModule>




This apart, IMUO we can achieve your htaccess settings in another way, mike this:
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript text/x-js text/ecmascript application/ecmascript text/vbscript text/fluffscript
AddOutputFilterByType DEFLATE image/svg+xml application/x-font-ttf application/x-font font/opentype font/otf font/ttf application/x-font-truetype application/x-font-opentype application/vnd.ms-fontobject application/vnd.oasis.opendocument.formula-template
AddOutputFilterByType DEFLATE text/xml application/xml
</IfModule>
<IfModule mod_expires.c>
<FilesMatch "\.(ico|gif|jpg|JPG|jpeg|png|PNG|swf|css|js|html?|xml|txt)$">
ExpiresActive On
ExpiresDefault "access plus 10 years"
</FilesMatch>
</IfModule>


Just a question of taste and simplicity
replace "10 years" expiration time by what you need.

To tune for each file, simply look this post:
Quote from: nend on August 11, 2010, 12:57:22 PM
# 1 YEAR
<FilesMatch "\.(ico|pdf|flv)$">
Header set Cache-Control "max-age=29030400, public"
</FilesMatch>
# 1 WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
# 2 DAYS
<FilesMatch "\.(xml|txt|css|js)$">
Header set Cache-Control "max-age=172800, proxy-revalidate"
</FilesMatch>
# 1 MIN
<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=60, private, proxy-revalidate"
</FilesMatch>


Anyway, good mod that many will use by far  ;)

Advertisement: