David Ko commited on
Commit
0e9cdf3
ยท
1 Parent(s): 1fb1877

chore(api): add no-cache headers to serve_static to prevent stale frontend assets

Browse files
Files changed (1) hide show
  1. api.py +6 -1
api.py CHANGED
@@ -1256,7 +1256,12 @@ def logout():
1256
  @app.route('/static/<path:filename>')
1257
  def serve_static(filename):
1258
  print(f"Serving static file: {filename}")
1259
- return send_from_directory(app.static_folder, filename)
 
 
 
 
 
1260
 
1261
  # ์ธ๋ฑ์Šค HTML ์ง์ ‘ ์„œ๋น™ (๋กœ๊ทธ์ธ ํ•„์š”)
1262
  @app.route('/index.html')
 
1256
  @app.route('/static/<path:filename>')
1257
  def serve_static(filename):
1258
  print(f"Serving static file: {filename}")
1259
+ resp = send_from_directory(app.static_folder, filename)
1260
+ # Prevent caching of static assets to reflect latest frontend changes
1261
+ resp.headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'
1262
+ resp.headers['Pragma'] = 'no-cache'
1263
+ resp.headers['Expires'] = '0'
1264
+ return resp
1265
 
1266
  # ์ธ๋ฑ์Šค HTML ์ง์ ‘ ์„œ๋น™ (๋กœ๊ทธ์ธ ํ•„์š”)
1267
  @app.route('/index.html')