forked from s3gw-tech/s3gw-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable caching of `index.html` on purpose so that the browser is always loading the latest app code, otherwise changes to the app are not taken into account when the browser is loading the file from the cache. Fixes: https://github.com/aquarist-labs/s3gw/issues/730 Signed-off-by: Volker Theile <[email protected]>
- Loading branch information
Showing
3 changed files
with
87 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Copyright 2023 SUSE LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from fastapi import FastAPI | ||
from fastapi.testclient import TestClient | ||
|
||
from s3gw_ui_backend import NoCacheStaticFiles | ||
|
||
|
||
def test_static_files_1() -> None: | ||
app = FastAPI() | ||
app.mount( | ||
"/", | ||
NoCacheStaticFiles(no_cache_files=["/test_api.py"], directory="api"), | ||
name="static", | ||
) | ||
client = TestClient(app) | ||
resp = client.get("/test_api.py") | ||
assert resp.status_code == 200 | ||
assert ( | ||
resp.headers["cache-control"] == "no-cache, max-age=0, must-revalidate" | ||
) | ||
assert resp.headers["expires"] == "0" | ||
assert resp.headers["pragma"] == "no-cache" | ||
|
||
|
||
def test_static_files_2() -> None: | ||
app = FastAPI() | ||
app.mount( | ||
"/", | ||
NoCacheStaticFiles(no_cache_files=["/test_api.py"], directory="api"), | ||
name="static", | ||
) | ||
client = TestClient(app) | ||
resp = client.get("/test_api_admin.py") | ||
assert resp.status_code == 200 | ||
assert "cache-control" not in resp.headers | ||
assert "expires" not in resp.headers | ||
assert "pragma" not in resp.headers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters