Jackie Makhija commited on
Commit
b9ab403
·
1 Parent(s): 124305e

Add no-cache headers to SPA responses

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -14,6 +14,14 @@ from unity_catalog_service import UnityCatalogService
14
  app = Flask(__name__, static_folder='.', static_url_path='')
15
  CORS(app)
16
 
 
 
 
 
 
 
 
 
17
  # Initialize services (lazy to allow mocking in tests)
18
  uc_service = None
19
  claude_client = None
@@ -313,15 +321,15 @@ Just describe what you want to do in natural language!""",
313
  @app.route('/', methods=['GET'])
314
  def index():
315
  """Serve the React UI"""
316
- return send_from_directory('.', 'index.html')
317
 
318
 
319
  @app.route('/<path:path>', methods=['GET'])
320
  def serve_static(path):
321
  """Serve static files"""
322
  if path and os.path.exists(path):
323
- return send_from_directory('.', path)
324
- return send_from_directory('.', 'index.html')
325
 
326
 
327
  @app.route('/api/chat', methods=['POST'])
 
14
  app = Flask(__name__, static_folder='.', static_url_path='')
15
  CORS(app)
16
 
17
+
18
+ def _no_cache(response):
19
+ """Disable caching for SPA assets to avoid stale UI (304s)."""
20
+ response.headers["Cache-Control"] = "no-store"
21
+ response.headers["Pragma"] = "no-cache"
22
+ response.headers["Expires"] = "0"
23
+ return response
24
+
25
  # Initialize services (lazy to allow mocking in tests)
26
  uc_service = None
27
  claude_client = None
 
321
  @app.route('/', methods=['GET'])
322
  def index():
323
  """Serve the React UI"""
324
+ return _no_cache(send_from_directory('.', 'index.html'))
325
 
326
 
327
  @app.route('/<path:path>', methods=['GET'])
328
  def serve_static(path):
329
  """Serve static files"""
330
  if path and os.path.exists(path):
331
+ return _no_cache(send_from_directory('.', path))
332
+ return _no_cache(send_from_directory('.', 'index.html'))
333
 
334
 
335
  @app.route('/api/chat', methods=['POST'])