Here is a great post on troubleshooting your AWS ELB.
The point that caught me out for about 10 hours today was that if you have your ELB configured for multiple Availability Zones, it doesnt matter if your assigned instance list doesn’t contain any instances from some of the AZs, it will still route traffic to those zones, which will get lost and result in a 503 (or 504/324).
So, DONT assign AZs that dont have any in-service instances running.
You want your site to issue far-future cache expiry values for resources like CSS and JS to reduce bandwidth usage and decrease page load speed.
However, when you release new code, you want everyone to receive this a.s.a.p.
But how do you achieve this when they all have cached versions that are cache-valid for a week or more?
Here’s what I do.
Create yourself a class such as this:
public static class Cacher
public static readonly string Value;
Value = DateTime.UtcNow.ToString("yyMMddHHmmssfff");
Then, change your script and css tags from:
<link rel="Stylesheet" type="text/css" href="/assets/css/all.css" />
<link rel="Stylesheet" type="text/css" href="/assets/css/<%: Cacher.Value %>/all.css" />
You can then use a mod_rewrite/asapi_rewrite rule to remove the value:
RewriteRule ^assets/css/[^/]+/all.css /assets/css/all.css [L,NC]
The reason you want the value in the path and not in the query string is that some caches refuse to cache content on URIs which include querys, regardless of the cache-control headers.
Alternatively, you could make the value be the current assembly version. It depends on your use-case.