From d7a41c813fc94c560d8ccad46e2d17dc38300b84 Mon Sep 17 00:00:00 2001 From: m-tartari <37861893+m-tartari@users.noreply.github.com> Date: Thu, 26 Sep 2024 16:29:23 +0200 Subject: [PATCH] fix(#72): disable http caching of `index.html` set response headers to: HTTP/1.1 200 OK Expires: Fri, May 11 2018 10:48:51 GMT Cache-Control: max-age=0, no-cache, no-store Pragma: no-cache --- src/modular/web/RobotDesignStudio.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/modular/web/RobotDesignStudio.py b/src/modular/web/RobotDesignStudio.py index 32eac1e..a26e96c 100755 --- a/src/modular/web/RobotDesignStudio.py +++ b/src/modular/web/RobotDesignStudio.py @@ -24,7 +24,7 @@ import numpy as np import rospy -from flask import Flask, Response, render_template, request, jsonify, send_from_directory, abort, session, send_file +from flask import Flask, Response, make_response, render_template, request, jsonify, send_from_directory, abort, session, send_file from apscheduler.schedulers.background import BackgroundScheduler import werkzeug @@ -192,7 +192,14 @@ def index(): last_updated= datetime.now(), ) - return render_template('index.html') + # for the index page we want to disable caching + index_page = make_response(render_template('index.html')) + # exparies in the past (date of the first commit of the project) + index_page.headers['Expires'] = 'Fri, May 11 2018 10:48:51 GMT' + index_page.headers['Cache-Control'] = 'max-age=0, no-cache, no-store' + index_page.headers['Pragma'] = 'no-cache' + return index_page + # Get workspace mode @app.route(f'{api_base_route}/mode', methods=['GET'])