News for hackers. Stuff that matters.
Re:S3 was down by scrollaway on Thursday September 14, 2017 @03:20PM (#15251592)
Quick tip for those using static (jekyll, hugo...) sites on s3: If you have cloudflare in front of it, you can turn on aggressive html caching by creating a page rule: example.com/* => Cache level => Cache everything

https://support.cloudflare.com/hc/en-us/articles/200172256-H...

This downtime made me realize we weren't caching any html on cloudflare. I just turned it on and all our static sites are doing fine now (and our bills are smaller!).

If you're fancy you can even programmatically purge the cache when you do CI deploys using the cloudflare API.

Re:S3 was down by seanwilson on Thursday September 14, 2017 @05:20PM (#15252613)
> Quick tip for those using static (jekyll, hugo...) sites on s3: If you have cloudflare in front of it, you can turn on aggressive html caching

> If you're fancy you can even programmatically purge the cache when you do CI deploys using the cloudflare API.

You need to be really careful with this.

I'm not sure how you've got things set up but isn't this going to lead to issues unless you have a cache busting or revalidation strategy? You can purge Cloudflare's cache but that's not going to purge the cache on browsers that already visited your site and cached a page already. You might get cases where an old cached HTML page is asking for page resources that don't exist anymore or pages break because the user is seeing the old HTML with the new CSS/JavaScript.

Also, if you can log in to your site, it can potentially cache one user's logged in page content and share it with others if your Cache-Control settings don't include "private".

You could set things up to make sure the browser and then the Cloudflare cache always asks your server first if a page has been updated recently (revalidation) but your server has to be configured right for this (e.g. etag or modified date usage).

Cloudflare is actually meant to have a feature that keeps a static version of your site to show in the event of outages:

https://www.cloudflare.com/always-online/

Re:S3 was down by scrollaway on Thursday September 14, 2017 @07:16PM (#15253277)
Unfortunately afaik Always Online does not work in the event of S3 errors because S3 is available, merely answering with HTTP error codes.
Re:S3 was down by seanwilson on Thursday September 14, 2017 @07:38PM (#15253399)
Hmm, can you explain further? What kind of error code? So Always Online only kicks in when there's no response and not e.g. 500 error codes?
Re:S3 was down by scrollaway on Thursday September 14, 2017 @08:30PM (#15253639)
Correct, AFAIK Always Online kicks in when the upstream cannot be reached (eg. connection timeout, unreachable dns etc).
Re:S3 was down by elithrar on Friday September 15, 2017 @01:50AM (#15254942)
You're both sort-of correct. AO kicks in on specific 5xx error codes: 502, 504, and then Cloudflare's 52x codes. It doesn't kick in on 500 or 503, or 4xx errors.

Ref: https://support.cloudflare.com/hc/en-us/articles/202238800-W...

Re:S3 was down by sfeng on Thursday September 14, 2017 @03:50PM (#15251889)
This is also a good time to get your static files deployed onto Azure or Google Cloud as well, and use your CDN or Cloudflare to failover.
Re:S3 was down by teej on Thursday September 14, 2017 @03:27PM (#15251670)
Won't help if your cache is empty and Cloudflare can't access S3. I originally discovered this service outage when an image in cloudflare was returning a 500 error about 40 minutes ago.
Re:S3 was down by scrollaway on Thursday September 14, 2017 @03:31PM (#15251708)
Yes and no. In outage periods, S3 access is often degraded because throttling is greatly increased, leading to 503s. Meaning if you have that cache layer on top of it, you dodge the issue.

Where it doesn't help is if Cloudflare itself is having issues (all it does is move the weak link one layer up in this case). But that is easy enough to disable (assuming the cloudflare API or dashboard is up).

Re:S3 was down by milankragujevic on Thursday September 14, 2017 @09:55PM (#15253996)
I don't think this is a good idea if you have lots of visits, as Cloudflare might ask you to upgrade to a Business account which is very expensive. It's excellent for small sites and blogs which are static, but for anything visited often, like a Docs site for some popular project, it might get dropped from CF's network. Don't quote me on that, I haven't experienced it, but I heard that they do ask people to upgrade, for example Brian Fritz of omdbapi.com, who had to close down the service to the public because of huge amounts of traffic, and that's just with text, not serving images or video...
Re:S3 was down by samstave on Thursday September 14, 2017 @04:04PM (#15252007)
This should be a default feature of Cloudflare going forward if they experience massive S3 issues through their customers...? Right?
Re:S3 was down by shallot_router on Thursday September 14, 2017 @04:28PM (#15252218)
Definitely not. If HTML caching were enabled by default, I would've run into all sorts of weird issues with a lot of my Cloudflare-protected sites.
Re:S3 was down by scrollaway on Thursday September 14, 2017 @04:07PM (#15252030)
I'm not sure why it would be a default feature. HTML caching should most definitely not be enabled by default.

However, I do agree that it should be possible to turn on without pagerules for these sorts of scenarios.

Re:S3 was down by dalanmiller on Thursday September 14, 2017 @05:10PM (#15252543)
Does this require paid subscription to Cloudflare?
Re:S3 was down by scrollaway on Thursday September 14, 2017 @05:10PM (#15252545)
It does not! It does take up a page rule though. You can have up to three page rules per domain for free.
Re:S3 was down by pmlnr on Thursday September 14, 2017 @04:09PM (#15252050)
Or you can host a mirror at home on a raspberry pi and redirect the dns when you have to.
Re:S3 was down by dna_polymerase on Thursday September 14, 2017 @06:41PM (#15253084)
Because DNS record propagation is absolutely great for this. Works within seconds!\s
Re:S3 was down by pmlnr on Friday September 15, 2017 @05:34AM (#15255792)
There is a TTL you can set in your record. Yes, you can set it to a second.

However, the case of a static website is not really hitting me as something can't afford a few seconds downtime...

Re:S3 was down by dna_polymerase on Friday September 15, 2017 @11:43AM (#15258072)
In my experience I can set the TTL to whatever value I want, last mile providers don't really give a shit about that and just cache it for how long they want.
Re:S3 was down by kccqzy on Thursday September 14, 2017 @03:23PM (#15251623)
Programmatically purging caches is slow and costs extra. Just use normal cache-busting techniques like a different URL after a deployment.

EDIT: Oops. Misread cloudflare/CloudFront.

Re:S3 was down by manigandham on Thursday September 14, 2017 @03:32PM (#15251718)
Cloudflare and all other modern CDNs do this instantly and for free. Only the legacy ones take longer (usually minutes at most) and might charge a small extra.
Re:S3 was down by jsjohnst on Thursday September 14, 2017 @03:40PM (#15251790)
Akamai takes far longer than a few minutes if you use all their POPs. It's in the 6-12hr range.
Re:S3 was down by jsizzle on Thursday September 14, 2017 @04:34PM (#15252274)
This is not true. Purges on akamai take less than ten minutes for entire cp codes or specific objects. Deploying new cache rules is less than an hour in many cases
Re:S3 was down by jsjohnst on Thursday September 14, 2017 @04:37PM (#15252297)
How many POPs are you using? I can assure you, I am not wrong here and have internal knowledge of why if you are truly using all POPs it takes so long.
Re:S3 was down by notyourday on Thursday September 14, 2017 @06:02PM (#15252873)
That's not correct. Site delivery on Akamai globally is purged within several minutes
Re:S3 was down by jsjohnst on Thursday September 14, 2017 @06:17PM (#15252948)
Look, I know what I'm talking about. Just because you can purge faster because of a different deployment doesn't mean that's the case for everyone. "Fast Purge" is not available for every type of deployment.
Re:S3 was down by nothrabannosir on Thursday September 14, 2017 @08:02PM (#15253501)
> Look, I know what I'm talking about.

Thanks for replying, but unless you're willing to explain to the rest of us why so, why bother? I can't make heads or tails of this pissing contest thread.

Re:S3 was down by notyourday on Friday September 15, 2017 @08:29AM (#15256540)
You are confused.

"Site Delivery" is purged globally within 7 minutes.

"Fast purge" enabled products (site delivery) is purged globally in under 20 seconds.

All assets for websites are site delivery. Only media services family of products are not site delivery. Those purge within a couple of hours. If you are someone who uses media services products, you know how to force Akamai to go back to origin globally instantaneously and how to trigger invalidation. In media services you should never serve stale.

Re:S3 was down by jsjohnst on Friday September 15, 2017 @02:56PM (#15259733)
As I said, it depends on your deployment. Thanks for the reply and confirming what I said was correct, that under some deployments it can be a multi-hour purge.
Re:S3 was down by sumobob on Thursday September 14, 2017 @08:40PM (#15253677)
the new fast purge utility is much faster too
Re:S3 was down by sgl75 on Thursday September 14, 2017 @03:29PM (#15251690)
Changing URLs is not really an option for html pages of a static site.
Re:S3 was down by jamiesonbecker on Thursday September 14, 2017 @03:57PM (#15251948)
Only for the root of a site, but there are better cache expiration options as noted elsewhere anyway.

For inner pages, browsers do consider /your-page-url?v=1505418887 to be a completely different page from /your-page-url?v=1505418888.

However, just expiring cache and/or properly setting HTTP cache control headers at most CDN's is a cleaner and more correct option.

Re:S3 was down by sgl75 on Thursday September 14, 2017 @04:07PM (#15252031)
I'm not following. How does that help my visitor see the latest version of the page when coming from a search engine or external site?
Re:S3 was down by jamiesonbecker on Thursday September 14, 2017 @06:17PM (#15252947)
Exactly, it doesn't. That's why you should use the actual cache mgmt options from your CDN provider, or just wait for your (properly configured) cache control headers to expire the cache (bear in mind that intermediate caching proxies don't always obey those TTLs or dates either).

I was just pointing out that some people adjust their menu links (etc) to include some sort of dynamic variable (ie /?ts=xxx). I don't recommend this sort of scheme, though, except in unusual circumstances: IMO, it's fragile, leaky, and inefficient.

Re:S3 was down by tokenizerrr on Thursday September 14, 2017 @03:39PM (#15251788)
No it's not? It's free to just purge everything.
Re:S3 was down by hamandcheese on Thursday September 14, 2017 @03:27PM (#15251669)
Thats fine for assets, but not at all ideal for pages.