Bird
0
0

How can you ensure Flask serves versioned static files to avoid browser caching old files after updates?

hard📝 Application Q9 of 15
Flask - Performance Optimization
How can you ensure Flask serves versioned static files to avoid browser caching old files after updates?
ARename the Flask app variable each time
BUse a query string or filename versioning in URLs
CDisable Flask's static file serving and use only CDN
DSet SEND_FILE_MAX_AGE_DEFAULT to 0 permanently
Step-by-Step Solution
Solution:
  1. Step 1: Understand cache busting

    Adding version info in URLs forces browsers to fetch new files.
  2. Step 2: Exclude unrelated options

    Setting cache to zero disables caching but is inefficient; renaming app or disabling static serving is unrelated.
  3. Final Answer:

    Use a query string or filename versioning in URLs -> Option B
  4. Quick Check:

    Versioned URLs prevent stale cache [OK]
Quick Trick: Add version to static URLs to bust cache [OK]
Common Mistakes:
MISTAKES
  • Disabling caching completely
  • Changing app variable name
  • Ignoring cache busting techniques

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes