Open akr4 opened 4 years ago
Interesting. Using cache control rather than a random token would definite be better. Would you be able to work up a pull request?
@akr4 how exactly does this work? Prerender needs to visit the site without CloudFront doing any caching. I can't see how Cache-Control would help here, that's nice when returning data from your origin, but after you rewrite the origin, prerender will visit the site as if it was a browser: how would you avoid caching then? I.e. you want to avoid caching for incoming requests.
Ah, I think I understand how this could work: on viewer-request check if the user-agent is "Prerender". In that case you should make sure a cached version is never returned. Not sure yet how.
Then on origin-response you set "Cache-Control".
@berenddeboer Returning the Cache-Control
header from origin-response prevents CloudFront from caching the response. In addition to that, you need to set a header in viewer-request to distinguish the request is from prerender.io. And add it to a cache key of your CloudFront settings.
Hello. This repo is very helpful. Thank you. I just want to tell about X-Prerender-Cachebuster. CloudFront respects Cache-Control header from Lambda@Edge functions. I set
Cache-Control: no-cache, no-store
in my origin-response function and works fine for me. https://aws.amazon.com/premiumsupport/knowledge-center/prevent-cloudfront-from-caching-files Hope this helps.