+ Reply to Thread
Results 1 to 6 of 6

Thread: http headers cache control

  1. #1
    peterac is offline x10Hosting Member peterac is an unknown quantity at this point
    Join Date
    Jun 2009
    Posts
    24

    http headers cache control

    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

  2. #2
    marshian's Avatar
    marshian is offline x10 Elder marshian is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    Belgium
    Posts
    526

    Re: http headers cache control

    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>
    Real programmers don't document their code - if it was hard to write, it should be hard to understand.

  3. #3
    peterac is offline x10Hosting Member peterac is an unknown quantity at this point
    Join Date
    Jun 2009
    Posts
    24

    Re: http headers cache control

    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

  4. #4
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,267

    Re: http headers cache control

    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.
    Nothing is always absolutely so.

  5. #5
    peterac is offline x10Hosting Member peterac is an unknown quantity at this point
    Join Date
    Jun 2009
    Posts
    24

    Re: http headers cache control

    Thanks descalzo
    Peter

  6. #6
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,267

    Re: http headers cache control

    BTW, there is a plugin for FireFox ( Live HTTP headers ) that lets you check the headers that are actually sent.
    Nothing is always absolutely so.

+ Reply to Thread

Similar Threads

  1. Subdomain and cache help
    By davejh in forum Programming Help
    Replies: 3
    Last Post: 05-28-2009, 10:35 PM
  2. DNS cache
    By galaxyAbstractor in forum Computers & Technology
    Replies: 4
    Last Post: 03-20-2009, 01:58 PM
  3. Need to clear my cache i guess..
    By Drewdog in forum Free Hosting
    Replies: 2
    Last Post: 04-06-2008, 02:53 PM
  4. Cache Problem?
    By Sohail in forum Free Hosting
    Replies: 7
    Last Post: 02-19-2008, 02:31 AM
  5. http digest authentication - Headers already sent?
    By altrock182182 in forum Free Hosting
    Replies: 0
    Last Post: 11-18-2007, 05:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers