Setting up cache control header in htacces files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • p3rsian
    Confirmed User
    • Sep 2003
    • 1050

    #1

    Setting up cache control header in htacces files

    i am trying to tell browsers to get a fresh copy of the site (JOOMLA based) after x hours using this code in htaccess.
    main question is if its ok to put PHP file in there . i could not find a site that has it but since its index.php homepage i need it.

    Code:
    # 2 HOURS
    <filesMatch "\.(html|htm|PHP|css|js)$">
    Header set Cache-Control "max-age=7200, must-revalidate"
    </filesMatch>
    thanx 4 helping
    boro en harfa chei
  • p3rsian
    Confirmed User
    • Sep 2003
    • 1050

    #2
    234567
    boro en harfa chei

    Comment

    • phypon
      Confirmed User
      • Oct 2003
      • 440

      #3
      I've only recently had experience with far future expires headers. Off the top of my head I don't think PHP will matter one way or another. HTML/CSS/js would be how content and images are displayed. Those would be what would need to be cached.

      Comment

      • AzteK
        Confirmed User
        • Feb 2001
        • 3451

        #4
        Originally posted by p3rsian
        i am trying to tell browsers to get a fresh copy of the site (JOOMLA based) after x hours using this code in htaccess.
        main question is if its ok to put PHP file in there . i could not find a site that has it but since its index.php homepage i need it.

        Code:
        # 2 HOURS
        <filesMatch "\.(html|htm|PHP|css|js)$">
        Header set Cache-Control "max-age=7200, must-revalidate"
        </filesMatch>
        thanx 4 helping
        to boro, batcheh mekhad htaccess yad begireh. Mamanet medooneh to enja hasty?

        Comment

        • RazorSharpe
          Confirmed User
          • Aug 2001
          • 2238

          #5
          Originally posted by AzteK
          to boro, batcheh mekhad htaccess yad begireh. Mamanet medooneh to enja hasty?
          Been a long while since I've heard Farsi
          Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

          Comment

          • AzteK
            Confirmed User
            • Feb 2001
            • 3451

            #6
            Originally posted by RazorSharpe
            Been a long while since I've heard Farsi
            toh az koja medooni?

            Comment

            • raymor
              Confirmed User
              • Oct 2002
              • 3745

              #7
              PHP or not doesn't matter. That's fine for all of the standards compliant browsers. The tricky part is that for IE you need to tell it to not cache in three different ways in order for it to be reliable.

              For older versions of IE, that needs to include in the <head> which must be placed at the ends of the document, or at very least place the caching adjectives at the end of the head. The problem is that since IE doesn't cache anything less than 512 bytes anyway, so when it refs the headers it hasn't yet decided to turn on cache, so that's too early to turn off the cache.

              On the other hand, IE doesn't know how to handle the Vary header, so it skips when thete is any Vary header. If you set it to Vary on hostname or URL that shouldn't hurt anything because OF COURSE different URLs have different content, but IE isn't smart enough to figure that out, so it skips caching.
              For historical display only. This information is not current:
              support&#64;bettercgi.com ICQ 7208627
              Strongbox - The next generation in site security
              Throttlebox - The next generation in bandwidth control
              Clonebox - Backup and disaster recovery on steroids

              Comment

              Working...