Announcement

Collapse
No announcement yet.

Cache Control header on Amazon CloudFront

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cache Control header on Amazon CloudFront

    I have upgraded www.carecure.net to 5.6.1pl1 (and applied the user.php fix). I have, for the first time, used the CDN options. I have set CDN URL to https://d2qzim9a7sklbv.cloudfront.net, which is our distribution.

    My pages emit a link to, for example, https://d2qzim9a7sklbv.cloudfront.ne...-rollup-561.js

    If I fetch that page with curl (curl -I 'https://d2qzim9a7sklbv.cloudfront.net/js/footer-rollup-561.js') I see this:
    Code:
    cache-control: max-age=1209600, private
    expires: Wed, 17 Jun 2020 15:50:42 GMT
    x-cache: Miss from cloudfront
    That private on the cache-control (as opposed to public) tells CloudFront not to cache the file. So it doesn't. That means CloudFront contacts my origin and fetches the file fresh each time a user asks for it.

    I don't understand why. My cache hit rate is like 30% and there's a lot of stuff like this not being cached. Most of the JavaScript in that footer-rollup-561.js is JQuery and stuff that doesn't change whether the user is logged in or not and should totally be cached by my CDN.

    How do I get that common JavaScript to be public cacheable?

  • #2
    The default .htaccess file for vBulletin 5.6.1 sets the cache control for Javascript to Public. If you're using a custom configuration or older .htaccess file then it may be different.

    Code:
    	<filesmatch "\.(ico|flv|gif|swf|eot|woff|otf|ttf|svg)$">
    		Header set Cache-Control "max-age=2592000, public"
    	</filesmatch>
    	<filesmatch "\.(jpg|jpeg|png)$">
    		Header set Cache-Control "max-age=1209600, public"
    	</filesmatch>
    	<filesmatch "\.(eot|woff|otf|ttf|svg)$">
    		Header set Cache-Control "max-age=2592000, public"
    	</filesmatch>
    	<filesmatch "\.(css)$">
    		Header set Cache-Control "max-age=31536000, public"
    	</filesmatch>
    	<filesmatch "\.(js)$">
    		Header set Cache-Control "max-age=1209600, public"
    	</filesmatch>
    This was actually changed in 5.5.1 - https://tracker.vbulletin.com/vbulle...sues/VBV-12047
    Translations provided by Google.

    Wayne Luke
    The Rabid Badger - a vBulletin Cloud demonstration site.
    vBulletin 5 API

    Comment


    • #3
      Awesome, thanks. The official upgrade instructions make no mention of changes to .htaccess, or how to know if you need to do them. The command line upgrader (which I use because we have almost 2M posts) doesn't check or mention .htaccess, either. There's no mention of modifications to the htaccess file in the 5.5.1 release notes. You can't run a real web site without customising your .htaccess file, so anyone who already has a working site and is upgrading will have their own, custom htaccess file. Deleting and replacing with the demo htaccess file isn't realistic for a large fraction of operators, so we have to know that there are changes to merge.

      I can't figure out how old my .htaccess file was. It had an explicit 'private' on the js and css lines. I wonder if a prior admin had been "too clever, by half" as they say.

      Comment


      • #4
        I am consistently impressed at how much of this stuff you know. How often the reply is exactly right. I think your documentation is doing you no favours because it doesn't anticipate a lot of common needs, but your answers in support are pretty much on point every time. Thanks for being fast and being right and being there all the time.

        Comment


        • #5
          When the .htaccess file is updated, it will be mentioned in the release announcement. The last update was done in 5.5.6.

          https://forum.vbulletin.com/forum/vb...e-for-download
          Translations provided by Google.

          Wayne Luke
          The Rabid Badger - a vBulletin Cloud demonstration site.
          vBulletin 5 API

          Comment


          • #6
            Originally posted by OldGrumpyDad View Post
            I am consistently impressed at how much of this stuff you know. How often the reply is exactly right. I think your documentation is doing you no favours because it doesn't anticipate a lot of common needs, but your answers in support are pretty much on point every time. Thanks for being fast and being right and being there all the time.
            I am in charge of the documentation as well. However, time to update it is sparse (as in none is scheduled) and answering customer questions comes first.
            Translations provided by Google.

            Wayne Luke
            The Rabid Badger - a vBulletin Cloud demonstration site.
            vBulletin 5 API

            Comment

            Related Topics

            Collapse

            Working...
            X