Sending Cache-control Headers Using Apache's header module
- Blogs:
NOTE: If you're using Apache 2.x go here.
I manage a fair number of Apache 1.3x web servers. Most of which are used for virtual hosting. After reading an article by Jeff Fulmer in SysAdmin Magazine entitled "Save Bandwidth and Increase Performance with Cache-control Response Headers" I decided to configure my Apache servers to use mod_header to send the Cache-control header for graphics files.
First I activated the mod_header module in Apache.
cd /<your path>/apache_1.3.x/src/modules/standard
/<your path>/apache/bin/apxs -a -i -n header -c mod_header.c
/<your path>/apache/bin/apachectl configtest
/<your path>/apache/bin/apachectl restart
Then I added a configuration directive for the main server configuration which sends the Cache-control header for common graphics.
<IfModule mod_header.c>
# graphics should stay cached for an hour (3600 sec)
<FilesMatch "\.(gif|jpg|jpeg|png)$">
Header set Cache-control max-age=3600
</FilesMatch>
</IfModule>
All that was left was to restart Apache and test everything.
/<your path>/apache/bin/apachectl configtest
/<your path>/apache/bin/apachectl restart
Testing was pretty 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
Bill Smit
Buy discount bactrim online
Drug Name
Bactrim (Sulfamethoxazole/Trimethoprim)
buy bactrim
Drug Uses
Bactrim is a synthetic antibacterial combination product available in DS (double strength) tablets.
How to use
Use Bactrim as directed by your doctor.
buy Nexium