Sending Cache-control Headers Using Apache 2.x and mod_expires
- Blogs:
About a year ago I wrote about how use mod_header with Apache 1.3x to send Cache-control headers. It worked so well that I want to configure my Apache 2.x servers to send the same headers. It's even simpler with Apache 2.x since mod_expires is included in most default installs. Here's what I did.
I added a configuration directive for the main server configuration (inside the Directory block) which sends the Cache-control header for common graphics.
<IfModule mod_expires.c>
# turn on the module for this directory
ExpiresActive on
# cache common graphics for 3 days
ExpiresByType image/jpg "access plus 3 days"
ExpiresByType image/gif "access plus 3 days"
ExpiresByType image/jpeg "access plus 3 days"
ExpiresByType image/png "access plus 3 days"
# cache CSS for 24 hours
ExpiresByType text/css "access plus 24 hours"
# set the default to 24 hours
ExpiresDefault "access plus 24 hours"
</IfModule>
All that was left was to restart Apache and test everything.
/<your path>/apache2/bin/apachectl configtest
/<your path>/apache2/bin/apachectl restart
Testing was simple. I tailed the access log and made two requests for the same page. The first request resulted with a flurry of files being requested (all the graphics being downloaded). The second request resulted in a single file request (no graphics) and the graphics where logged as HTTP status 304 (unmodified), success.
- geekwisdom's blog
- Login or register to post comments


Comments
tiffany jewelry Choose, buy
tiffany jewelry
Choose, buy and shop for on sale tiffany jewelry including Tiffany & Co Silver Necklace, Pendants, Bangles, Bracelets, Earrings, Rings and Accessories.
tiffany co
tiffany jewelry
Tiffany Jewellery offering bangle jewelry, bracelet jewelry, eardrop jewelry, necklace jewelry, ring jewelry, finger ring jewelry and earring jewelry
tiffany
tiffany and co
Tiffany Style Silver Jewelry: Rings, Earrings, Necklaces, Bracelets and more Tiffany Jewelry at low prices
Thank you for posting
Thank you for posting practical, real-world information about using Apache - useful and much appreciated. rather new in this stuff, I pay much attention to self-education. have used to find great blogs with useful pieces of information by search engine , but always search for smth more. really glad to find good ones.
Bill Smit
Do not use Ceftin if:
* you are allergic to any ingredient in Ceftin or to any other cephalosporin antibiotic (eg, cephalexin, cefprozil).Buy online ceftin
buy ceftin
Contact your doctor or health care provider right away if any of these apply to you.
buy Revatio
Doug TruesdellNote on