Developers
AvantGo Channel Developer Guide

TOC PREV NEXT INDEX


Server under control of your ISP

Look, I 'm no webmaster. I just have a small website with information about my favorite rock band. I cannot go around altering my ISP's server configurations.

That is true, but all is not lost. Email your local ISP support people and ask them how to set up caching headers. They will be glad to help you, once they realize you are reducing strain on their servers.

If your ISP is using Apache

Most likely, if they are using an Apache server, they will tell you to create or edit a file called .htaccess in your public HTML directory. This is a special file which allows you to change whatever you want in your directory without fear of messing up other people's files.

In this case, you would use the <Files> and <FilesMatch> directives instead of <Location>. They are fairly similar, except they generally only apply to files in the same directory as the .htaccess file you are editing. <Files> allows you to specify one particular file. <FilesMatch> allows you to specify many files, using UNIX-like regular expressions.

For example, your .htaccess file might look like:

<FilesMatch \.html> Header append

  Cache-Control "max-age=7200" </FilesMatch>

  <Files hourlyindex.html> Header unset

  Cache-Control Header append

  Cache-Control "max-age=3600" </Files>

  <FilesMatch photo.*\.(gif|jpg|jpeg|bmp)>

  Header append Cache-Control "max-age=43200"

  </FilesMatch>

This gives a max-age of 7200 to any file that includes .html in its name. To be more accurate, you might want to use \.html$ in the sample above, so that it only matches file names that end with .html. It gives a max-age of 3600 to the hourlyindex.html file. And it gives a max-age of 43200 to photo01.jpg, photo33.gif, photo56a.jpeg, etc.

Need a regular expression tutorial?

OK, all that stuff you just did with the *.(|\.*) punctuation really scares me.

Do not be scared. There is an excellent regular expression tutorial at:

http://www.perldoc.com/perl5.8.0/pod/perlretut.html

You probably do not need to get fancier than what we've included above.



TOC PREV NEXT INDEX