via icon indicating copy to clipboard operation
via copied to clipboard

Make sure that PDFs proxied by NGINX do get cached in Cloudflare

Open seanh opened this issue 4 years ago • 2 comments

The NGINX /proxy/static/ URLs for proxying PDFs need to end in ".pdf" or Cloudflare won't cache them (regardless of caching headers). See: https://hypothes-is.slack.com/archives/C1MA4E9B9/p1630943273021700?thread_ts=1630925851.005100&cid=C1MA4E9B9

In practice we only use this endpoint for proxying PDFs so we can probably get away with it always ending in ".pdf"?

NGINX may also need to strip caching-related headers from the third-party response and add its own caching headers in order to get Cloudflare to cach the responses. It looks like NGINX already does this: https://github.com/hypothesis/via/blob/c22a5a0ab37567a8580ae3568f46aa884ccce14b/conf/nginx/nginx.conf#L86-L89 See https://github.com/hypothesis/via/issues/31 and https://github.com/hypothesis/via/pull/76

seanh avatar Sep 06 '21 16:09 seanh

We could also create a Cloudflare page rule for the endpoint, then we wouldn't need to add/remove caching headers and the URLs wouldn't need to end in ".pdf".

Slack thread: https://hypothes-is.slack.com/archives/C1MA4E9B9/p1632303338068500

seanh avatar Sep 22 '21 10:09 seanh

We could also create a Cloudflare page rule for the endpoint, then we wouldn't need to add/remove caching headers and the URLs wouldn't need to end in ".pdf".

Created rule today. Waiting a day or two to see results.

marcospri avatar Sep 22 '21 13:09 marcospri