2

I recently started using AWS CloudFront to serve my static files with CDN. Since then, when I deploy updated static files such as js or css, CDN doesn't serve updated static files right away. Because of this, Python files (I'm using Django) or HTML files are shown wrong as they were supposed to be working correctly with updated static files.

I found this documentation. It says that I need to add identifier to the static files. For example, I have to change functions.js to functions_v1.js every time I deploy, so that CloudFront doesn't serve cached static files, but serve updated static files. I manually changed the updated static files, and it worked well. However, I felt like that's a hassle and there must be a better way so that I don't need to change all the updated file names one by one manually.

Can anyone give me a direction about this? I'm really confused about that.

3
  • 3
    Everybody does this. May 17, 2019 at 18:58
  • 1
    omg.. even when they have to change a lot of static files? do they just edit versions manually one by one? I thought there must've been an automated way :(
    – Jay
    May 17, 2019 at 19:17
  • 1
    There are automated ways - your build tool or development framework can handle it. Django has a number of solutions. stackoverflow.com/questions/9130555/…
    – ceejayoz
    May 17, 2019 at 20:46

1 Answer 1

1

Everybody does "cache busting", this very page has at least 5 versioned URIs. If you send a header to cache for a year, the browser isn't going to request it again for that long.

With tooling it does not have to be manual. Specifics about implementing this in your favorite content management system or web site generator are more of a topic for a web developer forums.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .