laurilehmijoki / s3_website

Manage an S3 website: sync, deliver via CloudFront, benefit from advanced S3 website features.
Other
2.24k stars 186 forks source link

Add support for CloudFlare cache clearing #134

Open ekristen opened 10 years ago

ekristen commented 10 years ago

I've chosen not to use CloudFront for multiple reasons and are already using CloudFlare, support for CloudFlare cache clearing via the API service for changes files would be fantastic.

Thanks again for this wonderful tool!

bjpirt commented 10 years ago

+1

I find hosting on S3 behind cloudflare to be a great combination - this would make deployments very smooth without having to log into cloudflare each time and nuke the cache.

laurilehmijoki commented 10 years ago

Out of curiosity, why do you need to invalidate the CloudFlare cache? I'm asking this, because it is possible to avoid the problem of cache-clearing by using cache-busting URLs.

In other words, if your static-site generator produces URLs such as /css/style.css?checksum=d3b07384d113edec49eaa6238ad5ff00 where d3b07384d113edec49eaa6238ad5ff00 is the MD5 checksum of your style.css file, you would not have to invalidate the CDN caches.

ekristen commented 10 years ago

I guess for the same reason that cloudfront is already supported to invalidate files there. However you bring up a good point, we could avoid cache problems by using cache busting urls, but this doesn't solve problems with like index.html or some other directory/index.html that gets loaded up, unless all urls have some random hash.

laurilehmijoki commented 10 years ago

Yes, there are cases when invalidating a CDN resource makes perfect sense.

However, I'm inclined to think that setting _maxage: 60 for HTML documents and generating a cache-busted URL with one-year max_age for any other resource is a good compromise between speed and simplicity of configuration.

I do understand that there is still room for clearig CloudFlare objects. Hence I find this feature request reasonable. I'm just trying to provide you alternative solutions.

ekristen commented 10 years ago

That makes perfect sense too. Thanks. I definitely will take a look at the CSS/JS stuff and the html max_age, see what sort of difficulty that'll be with jekyll.

ekristen commented 10 years ago

So the only problem with this workaround, or other solution is that unless you pay for the enterprise product of cloudflare, it does not honor the s3 cache headers, it uses its own (I assume to prevent abuse and to also get people to pay more)

laurilehmijoki commented 10 years ago

CloudFront honors the backend cache-headers. On the other hand, it does not offer a free plan

rafilkmp3 commented 7 years ago

any update ?

ghost commented 5 years ago

FWIW I've been using s3_website to deploy sites to AWS CloudFront for over two years. Even with a 20 year max_age and no use of asset fingerprinting whatsoever I have never had an issue with assets getting stuck in cache following an update—rendering a purge cache function useless.

Also, CloudFlare sets a cookie so using an alternative without cookies can help user privacy.