GoogleCloudPlatform/govanityurls

please set cache headers

Closed this issue · 2 comments

Thank you for this package, it makes setting up a vanity import path pretty easy indeed.

I noticed that no cache headers are set in any responses:

% curl -v <url>
< HTTP/2 200 
< content-type: text/html; charset=utf-8
< x-cloud-trace-context: e11dd858ab85c26bd488a27ac5deb139;o=1
< date: Sun, 24 Sep 2017 07:38:12 GMT
< server: Google Frontend
< content-length: 566
< alt-svc: quic=":443"; ma=2592000; v="39,38,37,35"
< 
<!DOCTYPE html>
[…]

When using CloudFlare in front of AppEngine, it is beneficial to set caching headers to reduce traffic to AppEngine. Currently, every request needs to go to AppEngine, even though the response will be exactly the same.

I suggest that cache headers should be included with every response, with the default cache time being 24 hours or so (configurable). This should be a good default, given how rarely the config changes in practice.

See https://support.cloudflare.com/hc/en-us/articles/202775670-How-Do-I-Tell-Cloudflare-What-to-Cache- for which headers CloudFlare respects.

Thank you for considering.

Maybe we should let people set arbitrary headers to be included in the responses. It can be provided in the app.yaml. By default, we can provide a cache header with a reasonable caching time. @zombiezen, any thoughts?

SGTM. Since the caching will be tied pretty directly with the configuration file, it seems like it ought to be the same value for each import path.

Happy to take up the issue if you want to assign it over to me. Change looks straightforward.