1
0
mirror of synced 2025-04-18 07:24:20 +03:00

Add Cache-Control no-cache,no-store,must-revalidate header to dynamically generated utils.js file. #3688

This commit is contained in:
Aditya Toshniwal 2025-04-16 11:23:35 +05:30
parent 934f17c65e
commit e8cb962890
11 changed files with 12 additions and 77 deletions

View File

@ -31,6 +31,7 @@ Housekeeping
Bug fixes
*********
| `Issue #3688 <https://github.com/pgadmin-org/pgadmin4/issues/3688>`_ - Add Cache-Control no-cache,no-store,must-revalidate header to dynamically generated utils.js file.
| `Issue #5266 <https://github.com/pgadmin-org/pgadmin4/issues/5266>`_ - Fixed an issue where shift + click on rows/columns for range selection did not work in the query tool data output window.
| `Issue #8443 <https://github.com/pgadmin-org/pgadmin4/issues/8443>`_ - Fixed an issue where the debugger hangs when stepping into nested function/procedure.
| `Issue #8497 <https://github.com/pgadmin-org/pgadmin4/issues/8497>`_ - Fixed an issue where the scroll position in the Object Explorer was not retained when switching workspaces.

View File

@ -61,7 +61,7 @@ from pgadmin.utils.master_password import validate_master_password, \
from pgadmin.model import User, db
from pgadmin.utils.constants import MIMETYPE_APP_JS, PGADMIN_NODE, \
INTERNAL, KERBEROS, LDAP, QT_DEFAULT_PLACEHOLDER, OAUTH2, WEBSERVER, \
VW_EDT_DEFAULT_PLACEHOLDER
VW_EDT_DEFAULT_PLACEHOLDER, NO_CACHE_CONTROL
from pgadmin.authenticate import AuthSourceManager
from pgadmin.utils.exception import CryptKeyMissing
@ -526,7 +526,7 @@ def utils():
shared_storage_list, \
restricted_shared_storage_list = get_shared_storage_list()
return make_response(
response = make_response(
render_template(
'browser/js/utils.js',
layout=layout,
@ -562,8 +562,10 @@ def utils():
"Administrator") else restricted_shared_storage_list,
enable_server_passexec_cmd=config.ENABLE_SERVER_PASS_EXEC_CMD,
max_server_tags_allowed=config.MAX_SERVER_TAGS_ALLOWED,
),
200, {'Content-Type': MIMETYPE_APP_JS})
), 200)
response.headers['Content-Type'] = MIMETYPE_APP_JS
response.headers['Cache-Control'] = NO_CACHE_CONTROL
return response
@blueprint.route("/js/endpoints.js")

View File

@ -89,17 +89,6 @@ def index():
)
@blueprint.route("/cloud.js")
@pga_login_required
def script():
"""render own javascript"""
res = Response(response=render_template(
"cloud/js/cloud.js", _=gettext),
status=200,
mimetype=MIMETYPE_APP_JS)
return res
@blueprint.route('/clear_cloud_session/',
methods=['POST'], endpoint='clear_cloud_session')
@pga_login_required

View File

@ -192,16 +192,6 @@ def index():
)
@blueprint.route("/utility.js")
@pga_login_required
def utility():
"""render the required javascript"""
return Response(response=render_template(
"file_manager/js/utility.js", _=gettext),
status=200,
mimetype=MIMETYPE_APP_JS)
@blueprint.route(
"/init", methods=["POST"], endpoint='init'
)

View File

@ -93,7 +93,7 @@ class AdHocConnectionSchema extends BaseUISchema {
this.api.get(url_for('sqleditor.get_new_connection_servers'))
.then(({data: respData})=>{
// Sort the server list
respData.data.result.server_list.Servers.sort(function (a, b) {
respData.data.result.server_list.Servers?.sort(function (a, b) {
return obj.pgAdmin.natural_sort(a.label, b.label);
});
let groupedOptions = [];

View File

@ -142,17 +142,6 @@ def index():
return bad_request(errormsg=_("This URL cannot be called directly."))
@blueprint.route("/js/import_export.js")
@pga_login_required
def script():
"""render the import/export javascript file"""
return Response(
response=render_template("import_export/js/import_export.js", _=_),
status=200,
mimetype=MIMETYPE_APP_JS
)
def _get_ignored_column_list(data, driver, conn):
"""
Get list of ignored columns for import/export.

View File

@ -72,17 +72,6 @@ class PSQLModule(PgAdminModule):
blueprint = PSQLModule('psql', __name__, static_url_path='/static')
@blueprint.route("/psql.js")
@pga_login_required
def script():
"""render the required javascript"""
return Response(
response=render_template("psql/js/psql.js", _=gettext),
status=200,
mimetype=MIMETYPE_APP_JS
)
@blueprint.route('/panel/<int:trans_id>',
methods=["POST"],
endpoint="panel")

View File

@ -108,7 +108,6 @@ class SqlEditorModule(PgAdminModule):
'sqleditor.initialize_sqleditor',
'sqleditor.initialize_sqleditor_with_did',
'sqleditor.filter_validate',
'sqleditor.filter',
'sqleditor.panel',
'sqleditor.close',
'sqleditor.update_sqleditor_connection',
@ -179,12 +178,6 @@ def index():
)
@blueprint.route("/filter", endpoint='filter')
@pga_login_required
def show_filter():
return render_template(MODULE_NAME + '/filter.html')
@blueprint.route(
'/initialize/viewdata/<int:trans_id>/<int:cmd_type>/<obj_type>/'
'<int:sgid>/<int:sid>/<int:did>/<int:obj_id>',
@ -1979,22 +1972,6 @@ def auto_complete(trans_id):
return make_json_response(data={'status': status, 'result': res})
@blueprint.route("/sqleditor.js")
@pga_login_required
def script():
"""render the required javascript"""
return Response(
response=render_template(
"sqleditor/js/sqleditor.js",
tab_size=blueprint.tab_size.get(),
use_spaces=blueprint.use_spaces.get(),
_=gettext
),
status=200,
mimetype=MIMETYPE_APP_JS
)
@blueprint.route('/load_file/', methods=["PUT", "POST"], endpoint='load_file')
@pga_login_required
def load_file():

View File

@ -1,3 +0,0 @@
<div class="filter-textarea">
<textarea id="sql_filter" rows="5" tabindex="0" aria-label="sql filter"></textarea>
</div>

View File

@ -28,7 +28,7 @@ from pgadmin.utils.ajax import make_response as ajax_response, \
make_json_response, bad_request, internal_server_error
from pgadmin.utils.csrf import pgCSRFProtect
from pgadmin.utils.constants import MIMETYPE_APP_JS, INTERNAL, \
SUPPORTED_AUTH_SOURCES
SUPPORTED_AUTH_SOURCES, NO_CACHE_CONTROL
from pgadmin.utils.validation_utils import validate_email
from pgadmin.model import db, Role, User, UserPreference, Server, \
ServerGroup, Process, Setting, roles_users, SharedServer
@ -99,7 +99,6 @@ def index():
@pgCSRFProtect.exempt
@pga_login_required
def current_user_info():
current_user.has_permission
return Response(
response=render_template(
"user_management/js/current_user.js",
@ -127,7 +126,7 @@ def current_user_info():
for p in r.get_permissions()})
),
headers={
'Cache-Control': 'no-cache, no-store, must-revalidate'
'Cache-Control': NO_CACHE_CONTROL
},
status=200,
mimetype=MIMETYPE_APP_JS

View File

@ -15,6 +15,8 @@ MIMETYPE_APP_HTML = 'text/html'
MIMETYPE_APP_JS = 'application/javascript'
MIMETYPE_APP_JSON = 'application/json'
NO_CACHE_CONTROL = 'no-cache, no-store, must-revalidate'
# Preference labels
PREF_LABEL_KEYBOARD_SHORTCUTS = gettext('Keyboard shortcuts')
PREF_LABEL_DISPLAY = gettext('Display')