Final thoughts on static files

Some tips

Project Source Code

Get the project source code below, and follow along with the lesson material.

Download Project Source Code

To set up the project on your local machine, please follow the directions provided in the README.md file. If you run into any issues with running the project source code, then feel free to reach out to the author in the course's Discord channel.

This lesson preview is part of the Serverless Django with Zappa course and can be unlocked immediately with a \newline Pro subscription or a single-time purchase. Already have access to this course? Log in here.

This video is available to students only
Unlock This Course

Get unlimited access to Serverless Django with Zappa, plus 70+ \newline books, guides and courses with the \newline Pro subscription.

Thumbnail for the \newline course Serverless Django with Zappa

Now that we've gone through the configuration for both white noise and S3, I wanted to share some final thoughts on static files. So what should you choose, white noise or S3? Actually, either way is fine. You really should pick the option that best meets your needs. We've gone through the pros and cons of each, and you can decide for yourself and for your project, which is the best path to take. But remember to always run collect static if you make changes to your files. One thing that's interesting about static files is caching. Caching tells the browsers to keep a file around. It also tells any middle systems between your AWS Lambda project and the client's browsers to keep the file around. This helps lower costs because the browser then keeps a copy of those files and doesn't have to go back to your AWS Lambda to get it. In fact, for some files that don't change very much, maybe your logo, you could configure the static file to be cached for a year or more. However, the downside of this system is that detecting changes is hard. So that when your logo does change, you have to tell all these systems that have kept copies of your logo that you have a new one now. And that is a difficult problem to solve. One way of approaching this is to use a content delivery network or a CDN. A CDN is a service with geographically distributed groups of servers. The goal is to provide a fast delivery of files to clients all over the world. And it works pretty well, but many CDNs charge for these services. I will note, usually you don't need these for small sites. So unless you really need fast delivery of files, I would skip this step until you're ready for it. While that's about it for static files, the next module we're going to learn how to use custom domain names to make our URLs much easier to read and more user-friendly.