Skip to content

Commit

Permalink
[Fixes #9042] Disable caching header in GeoNode proxy for the REST API (
Browse files Browse the repository at this point in the history
#9043) (#9047) (#9086)

Co-authored-by: Alessio Fabiani <[email protected]>

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Alessio Fabiani <[email protected]>
  • Loading branch information
github-actions[bot] and Alessio Fabiani authored Apr 12, 2022
1 parent 4b9b5d7 commit 68102b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions geonode/geoserver/tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1261,3 +1261,10 @@ def test_set_resources_links(self):
_post_migrate_link_meta,
f"No '{name}' links have been found in the catalogue for the resource '{_lyr.alternate}'"
)

@on_ogc_backend(geoserver.BACKEND_PACKAGE)
def test_gs_proxy_never_caches(self):
url = reverse('gs_styles')
response = self.client.get(url)
self.assertTrue(response.has_header('Cache-Control'))
self.assertEqual(response.headers.get('Cache-Control'), 'max-age=0, no-cache, no-store, must-revalidate, private')
4 changes: 2 additions & 2 deletions geonode/geoserver/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
_invalidate_geowebcache_layer)

from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.cache import cache_control
from django.views.decorators.cache import never_cache

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -470,7 +470,7 @@ def strip_prefix(path, prefix):


@csrf_exempt
@cache_control(public=True, must_revalidate=True, max_age=30)
@never_cache
def geoserver_proxy(request,
proxy_path,
downstream_path,
Expand Down

0 comments on commit 68102b8

Please sign in to comment.