Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Cache Control Headers #2

Closed
aselbie opened this issue May 15, 2014 · 4 comments
Closed

Missing Cache Control Headers #2

aselbie opened this issue May 15, 2014 · 4 comments

Comments

@aselbie
Copy link

aselbie commented May 15, 2014

The lack of cache control headers on the main background image is causing Chrome to reload that image on every page.

@jcoppieters
Copy link
Owner

I agree. And even more important if you know that Cody caches these (static) images in memory, so they can't change anyway as long as they are in the ram cache (until they get thrown out - or the server is restarted)

Care to make me the examples / tell me what to do? I'll incorporate it in the static server (images, javascript and css files) asap.

Johan C.

@aselbie
Copy link
Author

aselbie commented May 15, 2014

Well, I've never had to mess with it before, because I believe the default settings in Apache/nginx send them. But based on http://www.mobify.com/blog/beginners-guide-to-http-cache-headers/ I would think updating like so would work:

self.response.writeHead(200, { "Content-Type": type });

in Static.js would become

self.response.writeHead(200, { 
    "Content-Type": type,
    "Cache-Control": "public, max-age=86400"
});

86,400 being one day in seconds. So you could play with that depending on how long you would like your images to be cached.

@pvencill
Copy link

Ideally that max-age is something you'd set in the site config.

@jcoppieters
Copy link
Owner

Ok fixed and pushed to Git.
I've added the "Cache-Control" header in the static and dynamic file server. Defaults resp. 1 day and 10 minutes. Times both already in a variable, but this should come from a config.js/json file at the start of an application.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants