0 points

a week ago

HackerStash adds Cloudfront for Local Caching

HackerStash update by Avatar Harry King in Product Update

You may notice the site is slightly faster now, this is because we've been able to flip the switch on Cloudfront, Amazon's CDN service. It nows sits in front of our ALB (Application Load Balancer).

To ensure we're caching the right things, I set the Cloudfront default to 0, and then we added cache-control headers on the content we wanted to insulate. We also needed to set an X-Forwarded-Host header in Cloudfront to ensure the backend was able to properly understand where certain requests were landing in your browser, to ensure features like OAuth continued to work.

Static content like images, css and javascript get cached for a year, and some text content gets cached for a couple of seconds. If I've tuned it right, you shouldn't notice it's there, but it should give us some insulation if we did get some large scale attention.

I'm pretty happy with our score now, that C for Compress Transfer is down to an under-optimised favicon, which is a minor issue, but will be fixed soon, and should get us A's across the board.

Another nice benefit of using Cloudfront is the server side analytics they capture for us, which means we get just enough information to be useful, without having to add intrusive Google Analytics to the site, which hopefully is a small win for privacy.

Does the site feel faster to you? Is anything weird happening? Let me know in the comments.

Update: @LemonJS has made some quick fixes and we're now A across the board!