http headers cache control

peterac

New Member
Messages
24
Reaction score
0
Points
1
Hi, can anybody help with setting cache control http headers on X10(stoli). After googling it seems the way in is through . htaccess files ? now i am lost
Peter
 

marshian

New Member
Messages
526
Reaction score
9
Points
0
It's possible to add headers with other methods, but using .htaccess files is certainly a good method.
You can have one .htaccess file per directory, which is logical, since two files with the same name aren't allowed. They contain instructions/settings for Apache, just like httpd.conf, but on a per-directory base.
For every HTTP request, Apache will look for every .htaccess file that applies to that request. This is the .htaccess file in the current directory, the one in the parent directory, parent of the parent, etc.
You can do a lot of useful things with .htaccess files, but I'll just tell you how to add headers. If you want to add certain headers to all files in a directory and all subdirectories, just add the following in your .htaccess:
Code:
#Additional headers
Header set Cache-Control "private, max-age=5184000"
Header set Last-Modified "Wed, 12 Aug 2009 00:00:00 GMT"
Where you -obviously- change the header name and contents.
It's also possible to do this on a per-file basis:
Code:
#(This is a comment.)
#I'm not sure how you can specify multiple files, but it's probably something like this:
#<Files "a.php" "b.php" "c.php">
<Files something.php>
  Header set Cache-Control "private, max-age=5184000"
  Header set Last-Modified "Wed, 12 Aug 2009 00:00:00 GMT"
</Files>
It's also possible to specify a directory, simply change <Files> into <Directory>.
The most useful variant however uses regex to find out which files it applies to, saving you the time from specifying all files manually.
Code:
<FilesMatch "\.(html|htm|php)$">
  Header set Cache-Control "private, max-age=5184000"
  Header set Last-Modified "Wed, 12 Aug 2009 00:00:00 GMT"
</FilesMatch>
 

peterac

New Member
Messages
24
Reaction score
0
Points
1
Thanks Marshian, the current htaccess in the dir is
# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName tnqsupportgroup.x10hosting.com
AuthUserFile /home/peterac/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/peterac/public_html/_vti_pvt/service.grp

I am presume I just add the to lines at the end of this?

my apache knowledge is nil and the tutorials are not helping.
thank you
Peter
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Yes. Just add it the bottom of the file.

Check a page. If you get a 500 error, you did something wrong. You can just delete the new lines to get back to normal.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
BTW, there is a plugin for FireFox ( Live HTTP headers ) that lets you check the headers that are actually sent.
 
Top