Python for Entrepreneurs Transcripts
Chapter: Web design foundations
Lecture: Cache busting: Introduction
0:02 Let's talk about stale static files. Remember when we talked about Pyramid and the static folder - its whole purpose is to cache things,
0:11 and make sure that our page loads as fast as possible. But when we are trying to develop the site or deploy new versions of the site,
0:18 this can be problematic. So imagine, we've started out with this CSS file in the very standard black text on the white background.
0:27 So here our body has the color black and the background of white, and it looks like this- that's pretty decent,
0:34 you can see the white background and the black text. Maybe we decide for some reason we want to change the styles,
0:40 or like, hey, wouldn't it be cool if we could make like a dark version where the font is white and the color is very dark grey or something like that?
0:49 And we either edit this and try to load it for ourselves or we push it to production and visitors who have been there before
0:56 and previously cached the original site.css, come back and when they view the page, it still looks the same
1:02 or when we are developing it and we view the page, it still looks the same and this is totally frustrating,
1:08 I want you to wear two hats when you think about this problem - on one hand, it's annoying for you as a developer constantly changing your site
1:37 Now, there are ways that you can tweak your browser, say if you turn on the developer tools and say: "While I'm in developer tool mode
1:44 don't cache this." But think about it from the perspective of deployment as well,
1:49 there is no way you can go to all the users and go have you been here before, you might need to force refresh your browser
1:56 so you can see the new site and if you don't, it's going to look like crap, so I am going to show you a really simple technique
2:02 that will solve this problem 100% of the time. You'll get maximum cache value,
2:07 you could set the cache duration to like a year or two years or ten years, it wouldn't matter, the second you deploy a new version,
2:14 if there is a change, users will download it, there is no change, they'll use the cached version. Similarly for you while you are developing it.
2:22 So, this may seem like it's a little bit of an advanced topic, getting in the head of just basic styling box model layout and so on,
2:29 but I wanted to put this first, so that we don't worry about these problems again like I'm so over dealing with "Oh is that thing fresh,
2:38 do I have the latest version?" You'll see it's super easy to solve this problem
2:41 and if we tackle it now, we won't have to worry about it for the entire rest of the class.