WebFaction
Community site: login faq

I'd like to serve some static files for an https site I have. I want the HTTP cache-control header to be set to public so that browsers will cache the files on disk. Is this done by default? Do I have to enable it? If so how?

asked 28 Oct '10, 13:10

Adam's gravatar image

Adam
18179
accept rate: 0%


It's not done by default. If you need to set cache headers, then use a Static/CGI/PHP app to serve your static media, and and set your cache-control header via .htaccess, eg:

Header set Cache-Control "public"

Hope that helps!

permanent link

answered 28 Oct '10, 13:30

seanf's gravatar image

seanf ♦♦
11.9k21333
accept rate: 37%

Is that still the way to do it, in 2013, using nginx?

I just setup a static/cgi/php app. My htaccess file looks like this:

Action php54-cgi /php54.cgi
<FilesMatch \.php$>
  SetHandler php54-cgi
</FilesMatch>

<FilesMatch "\.(css|png|jpg|gif|ico|pdf|flv|js)$">
Header set Cache-Control "max-age=172800, public, must-revalidate"
</FilesMatch>

But the https response header does not contain does not contain cache control.

Thanks

permanent link

answered 01 Mar '13, 21:11

cwurld2's gravatar image

cwurld2
5137
accept rate: 0%

Our nginx (static only) application allows no configuration. The above would be for Apache(Static/PHP/CGI). You may submit a support ticket and we can investigate why it is failing for you.

(01 Mar '13, 21:37) johns ♦♦ johns's gravatar image

Thanks. I think I found the problem. My static app is part of a website. I deleted and recreated the static app to try different configurations. I used the same name every time. The server continued to server the content. Later I found that my website no longer contained the static app. I am not sure why the server continued to server the static files. But this appears to be why the changes I made did not change the header of the static files. Seems to be working now.

(02 Mar '13, 11:32) cwurld2 cwurld2's gravatar image

As a follow-up, I got browser caching to work with my HTTPS static content using a webfaction static only app (nginx) and the setting "expires max". To deal with the problem of a cache time of years, I used the Django CachedStaticFilesStorage. This adds a hash of the file content to the filename.

(02 Mar '13, 15:50) cwurld2 cwurld2's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×183
×121
×86
×70
×28

question asked: 28 Oct '10, 13:10

question was seen: 5,756 times

last updated: 02 Mar '13, 15:50

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2017 PARAGON INTERNET GROUP LIMITED
WEBFACTION IS A SERVICE OF PARAGON INTERNET GROUP LIMITED
REGISTERED IN ENGLAND AND WALES 7573953 - VAT REGISTRATION NUMBER 182147021
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM