Bird
0
0

What is wrong with this Flask snippet for static file caching?

medium📝 Debug Q7 of 15
Flask - Performance Optimization
What is wrong with this Flask snippet for static file caching?
app = Flask(__name__)
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = -100
AFlask will cache files forever
BNegative cache duration is invalid and ignored
CThis sets cache duration to 100 seconds
DNo error; negative values disable caching
Step-by-Step Solution
Solution:
  1. Step 1: Understand cache duration limits

    Negative values are invalid and Flask ignores them or uses default.
  2. Step 2: Exclude incorrect interpretations

    Negative does not mean forever caching or 100 seconds.
  3. Final Answer:

    Negative cache duration is invalid and ignored -> Option B
  4. Quick Check:

    Cache duration must be non-negative [OK]
Quick Trick: Cache duration cannot be negative [OK]
Common Mistakes:
MISTAKES
  • Assuming negative disables caching
  • Thinking negative sets positive time
  • Ignoring invalid config values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes