Cache it if you can
Posted on: 19th December 2020
Forgive the cheesy title. I have been experimenting with how to make my static site perform better in terms of load time by using a CDN and I have arrived at the conclusion that I don’t need a CDN 😅️.
CDNs are effective if the website
- has a reasonably high traffic
- is being accessed from all over the world
- is resource heavy
My static site meets none of the criteria.
Whatever cache control BunnyCDN provided, I can easily control that via nginx. Having the CDN was just.. extra. Also, I was kinda annoyed at all the extra stuff added to each post to tell Jekyll where to link the resources from. BunnyCDN can prevent a DoS attack if there ever was one but that’s a very unlikely scenario. There’s something else that I learned while exploring the options for nginx. Cache busting! It basically changes the version number of the resource you are caching so that new content gets loaded instead of the old one. I can set the cache for images for a really long time because once posted they won’t change. Plus, all the current images have been optimized rather aggressively. It’s also a very unlikely scenario that somebody is going to visit the same page twice. I am content with how the stylesheet is now so caching it should help make the site faster for the one person who reads this 😄️. Besides, the Atom feed is an excellent way to catch up on any updates from my corner of the small web 😊️.
Day 61 - Join Me in #100DaysToOffloadtags: 100daystooffload cdn