logo
Apache Lounge
Webmasters

 


About

Forum Index Downloads Search Register Log in  RSS Apache Lounge
 



Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Apache Lounge is not sponsored.

Your donations will help to keep this site alive and well, and continuing building binaries.



Speed Up Sites with htaccess Caching

 
Post new topic   Reply to topic    Apache Forum Index -> How-to's & Documentation & Tips



View previous topic :: View next topic  
Author Message
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 6255
Location: Germany, Next to Hamburg

PostPosted: Tue 31 Jul '07 17:37    Post subject: Speed Up Sites with htaccess Caching Reply with quote

This article shows 2 awesome ways to implement caching on your website using Apache .htaccess (httpd.conf) files on the Apache Web Server. Both methods are extremely simple to set up and will dramatically speed up your site

Apache .htaccess caching code
Code:

# 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|php)$">
Header set Cache-Control "max-age=60, private, proxy-revalidate"
</FilesMatch>


For fail-safe code implement this to the above
Code:

<IfModule mod_expires.c>
# any Expires Directives go here
</IfModule>
 
<IfModule mod_headers.c>
# any Header directives go here
</IfModule>


At least one of the 2 modules needs to be built into Apache; although they are included in the distribution, they are not turned on by default. To find out if the modules are enabled in your server, find the httpd binary and run httpd -l; this should print a list of the available modules. The modules we’re looking for are mod_expires and mod_headers.

---
edit:

Win32 Build has this modules by default, you only need to enable it.


This was a short version of http://www.askapache.com/htaccess/speed-up-sites-with-htaccess-caching.html

Have some fun!
Back to top
flyingmonkey



Joined: 01 Aug 2007
Posts: 15

PostPosted: Thu 06 Sep '07 2:19    Post subject: Reply with quote

Will this work for Apache configured as a reverse proxy where all traffic is encrypted via SSL from the backend to the reverse proxy and again to the client?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 6255
Location: Germany, Next to Hamburg

PostPosted: Thu 06 Sep '07 10:01    Post subject: Reply with quote

I haven't tested it with SSL reverse proxy. But I think it should. The encryption has nothing to do with with the age control. You may have a try.
Back to top


Post new topic   Reply to topic    Apache Forum Index -> How-to's & Documentation & Tips
Page 1 of 1