Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Speed Up Sites with htaccess Caching |
|
Author |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Tue 31 Jul '07 17:37 Post subject: Speed Up Sites with htaccess Caching |
|
|
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
|
Posted: Thu 06 Sep '07 2:19 Post subject: |
|
|
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: 7373 Location: Germany, Next to Hamburg
|
Posted: Thu 06 Sep '07 10:01 Post subject: |
|
|
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 |
|
|
|
|
|
|