Skip to content

Commit e8cb962

Browse files
Add Cache-Control no-cache,no-store,must-revalidate header to dynamically generated utils.js file. pgadmin-org#3688
1 parent 934f17c commit e8cb962

File tree

11 files changed

+12
-77
lines changed

11 files changed

+12
-77
lines changed

docs/en_US/release_notes_9_3.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Housekeeping
3131
Bug fixes
3232
*********
3333

34+
| `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.
3435
| `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.
3536
| `Issue #8443 <https://github.com/pgadmin-org/pgadmin4/issues/8443>`_ - Fixed an issue where the debugger hangs when stepping into nested function/procedure.
3637
| `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.

web/pgadmin/browser/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
from pgadmin.model import User, db
6262
from pgadmin.utils.constants import MIMETYPE_APP_JS, PGADMIN_NODE, \
6363
INTERNAL, KERBEROS, LDAP, QT_DEFAULT_PLACEHOLDER, OAUTH2, WEBSERVER, \
64-
VW_EDT_DEFAULT_PLACEHOLDER
64+
VW_EDT_DEFAULT_PLACEHOLDER, NO_CACHE_CONTROL
6565
from pgadmin.authenticate import AuthSourceManager
6666
from pgadmin.utils.exception import CryptKeyMissing
6767

@@ -526,7 +526,7 @@ def utils():
526526
shared_storage_list, \
527527
restricted_shared_storage_list = get_shared_storage_list()
528528

529-
return make_response(
529+
response = make_response(
530530
render_template(
531531
'browser/js/utils.js',
532532
layout=layout,
@@ -562,8 +562,10 @@ def utils():
562562
"Administrator") else restricted_shared_storage_list,
563563
enable_server_passexec_cmd=config.ENABLE_SERVER_PASS_EXEC_CMD,
564564
max_server_tags_allowed=config.MAX_SERVER_TAGS_ALLOWED,
565-
),
566-
200, {'Content-Type': MIMETYPE_APP_JS})
565+
), 200)
566+
response.headers['Content-Type'] = MIMETYPE_APP_JS
567+
response.headers['Cache-Control'] = NO_CACHE_CONTROL
568+
return response
567569

568570

569571
@blueprint.route("/js/endpoints.js")

web/pgadmin/misc/cloud/__init__.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,6 @@ def index():
8989
)
9090

9191

92-
@blueprint.route("/cloud.js")
93-
@pga_login_required
94-
def script():
95-
"""render own javascript"""
96-
res = Response(response=render_template(
97-
"cloud/js/cloud.js", _=gettext),
98-
status=200,
99-
mimetype=MIMETYPE_APP_JS)
100-
return res
101-
102-
10392
@blueprint.route('/clear_cloud_session/',
10493
methods=['POST'], endpoint='clear_cloud_session')
10594
@pga_login_required

web/pgadmin/misc/file_manager/__init__.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,6 @@ def index():
192192
)
193193

194194

195-
@blueprint.route("/utility.js")
196-
@pga_login_required
197-
def utility():
198-
"""render the required javascript"""
199-
return Response(response=render_template(
200-
"file_manager/js/utility.js", _=gettext),
201-
status=200,
202-
mimetype=MIMETYPE_APP_JS)
203-
204-
205195
@blueprint.route(
206196
"/init", methods=["POST"], endpoint='init'
207197
)

web/pgadmin/misc/workspaces/static/js/AdHocConnection.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class AdHocConnectionSchema extends BaseUISchema {
9393
this.api.get(url_for('sqleditor.get_new_connection_servers'))
9494
.then(({data: respData})=>{
9595
// Sort the server list
96-
respData.data.result.server_list.Servers.sort(function (a, b) {
96+
respData.data.result.server_list.Servers?.sort(function (a, b) {
9797
return obj.pgAdmin.natural_sort(a.label, b.label);
9898
});
9999
let groupedOptions = [];

web/pgadmin/tools/import_export/__init__.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,6 @@ def index():
142142
return bad_request(errormsg=_("This URL cannot be called directly."))
143143

144144

145-
@blueprint.route("/js/import_export.js")
146-
@pga_login_required
147-
def script():
148-
"""render the import/export javascript file"""
149-
return Response(
150-
response=render_template("import_export/js/import_export.js", _=_),
151-
status=200,
152-
mimetype=MIMETYPE_APP_JS
153-
)
154-
155-
156145
def _get_ignored_column_list(data, driver, conn):
157146
"""
158147
Get list of ignored columns for import/export.

web/pgadmin/tools/psql/__init__.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,6 @@ def get_exposed_url_endpoints(self):
7272
blueprint = PSQLModule('psql', __name__, static_url_path='/static')
7373

7474

75-
@blueprint.route("/psql.js")
76-
@pga_login_required
77-
def script():
78-
"""render the required javascript"""
79-
return Response(
80-
response=render_template("psql/js/psql.js", _=gettext),
81-
status=200,
82-
mimetype=MIMETYPE_APP_JS
83-
)
84-
85-
8675
@blueprint.route('/panel/<int:trans_id>',
8776
methods=["POST"],
8877
endpoint="panel")

web/pgadmin/tools/sqleditor/__init__.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ def get_exposed_url_endpoints(self):
108108
'sqleditor.initialize_sqleditor',
109109
'sqleditor.initialize_sqleditor_with_did',
110110
'sqleditor.filter_validate',
111-
'sqleditor.filter',
112111
'sqleditor.panel',
113112
'sqleditor.close',
114113
'sqleditor.update_sqleditor_connection',
@@ -179,12 +178,6 @@ def index():
179178
)
180179

181180

182-
@blueprint.route("/filter", endpoint='filter')
183-
@pga_login_required
184-
def show_filter():
185-
return render_template(MODULE_NAME + '/filter.html')
186-
187-
188181
@blueprint.route(
189182
'/initialize/viewdata/<int:trans_id>/<int:cmd_type>/<obj_type>/'
190183
'<int:sgid>/<int:sid>/<int:did>/<int:obj_id>',
@@ -1979,22 +1972,6 @@ def auto_complete(trans_id):
19791972
return make_json_response(data={'status': status, 'result': res})
19801973

19811974

1982-
@blueprint.route("/sqleditor.js")
1983-
@pga_login_required
1984-
def script():
1985-
"""render the required javascript"""
1986-
return Response(
1987-
response=render_template(
1988-
"sqleditor/js/sqleditor.js",
1989-
tab_size=blueprint.tab_size.get(),
1990-
use_spaces=blueprint.use_spaces.get(),
1991-
_=gettext
1992-
),
1993-
status=200,
1994-
mimetype=MIMETYPE_APP_JS
1995-
)
1996-
1997-
19981975
@blueprint.route('/load_file/', methods=["PUT", "POST"], endpoint='load_file')
19991976
@pga_login_required
20001977
def load_file():

web/pgadmin/tools/sqleditor/templates/sqleditor/filter.html

Lines changed: 0 additions & 3 deletions
This file was deleted.

web/pgadmin/tools/user_management/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
make_json_response, bad_request, internal_server_error
2929
from pgadmin.utils.csrf import pgCSRFProtect
3030
from pgadmin.utils.constants import MIMETYPE_APP_JS, INTERNAL, \
31-
SUPPORTED_AUTH_SOURCES
31+
SUPPORTED_AUTH_SOURCES, NO_CACHE_CONTROL
3232
from pgadmin.utils.validation_utils import validate_email
3333
from pgadmin.model import db, Role, User, UserPreference, Server, \
3434
ServerGroup, Process, Setting, roles_users, SharedServer
@@ -99,7 +99,6 @@ def index():
9999
@pgCSRFProtect.exempt
100100
@pga_login_required
101101
def current_user_info():
102-
current_user.has_permission
103102
return Response(
104103
response=render_template(
105104
"user_management/js/current_user.js",
@@ -127,7 +126,7 @@ def current_user_info():
127126
for p in r.get_permissions()})
128127
),
129128
headers={
130-
'Cache-Control': 'no-cache, no-store, must-revalidate'
129+
'Cache-Control': NO_CACHE_CONTROL
131130
},
132131
status=200,
133132
mimetype=MIMETYPE_APP_JS

0 commit comments

Comments
 (0)