Use Cloudflare CDN for static assets
Description of the issue 📄
During a past incident I learned that Rails is serving up static assets, which is completely unnecessary. We already have the domain set up with Cloudflare, so we may as well use their CDN and save some load on the Rails app.
Screenshots 📷
Go look at the log files ;)
Steps to fix ðŸ›
https://www.bigbinary.com/blog/using-cloudflare-as-cdn-for-rails-applications
To do 📋
- [x] Claim this issue (comment below, or assign yourself if you are part of the codebar org)
- [ ] Fork and clone the repository
- [ ] Update the relevant files. Follow the steps to fix section in this issue.
- [ ] Commit your changes as one commit. Use the title of this issue as your commit message
- [ ] Submit a pull request
- [ ] Mention this issue in the PR description by including it's number
- [ ] Have your pull request reviewed & merged by a codebar team member
I claim this issue!
We probably don't want to cache everything in public/ for the suggested duration of one year, as that's also where the sitemap.xml will get served from.
This article suggests a solution that might work for us: https://appsintheopen.com/posts/64-rails-page-caching-cache-headers-and-thruster
It seems that CloudFlare does cache some assets, but there are still requests coming through to the Rails app. This warrants more detailed investigation, before modifying the application and CloudFlare configuration.