Skip to content

Commit

Permalink
Merge pull request #1354 from uktrade/GP2-2835--disable-homepage-cache
Browse files Browse the repository at this point in the history
Reverting disable homepage cache and removed cache middleware
  • Loading branch information
webbyfox authored Jun 2, 2021
2 parents dac444f + 293075c commit e816425
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 35 deletions.
2 changes: 0 additions & 2 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
]

MIDDLEWARE = [
'wagtailcache.cache.UpdateCacheMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
Expand All @@ -93,7 +92,6 @@
'core.middleware.UserSpecificRedirectMiddleware',
'core.middleware.UserLocationStoreMiddleware',
'core.middleware.StoreUserExpertiseMiddleware',
'wagtailcache.cache.FetchFromCacheMiddleware',
'core.middleware.CheckGATags',
]

Expand Down
6 changes: 0 additions & 6 deletions domestic/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from wagtail.core.models import Page
from wagtail.images import get_image_model_string
from wagtail.images.edit_handlers import ImageChooserPanel
from wagtailcache.cache import WagtailCacheMixin

from core import (
blocks as core_blocks,
Expand Down Expand Up @@ -136,7 +135,6 @@ class DomesticHomePage(
mixins.EnableTourMixin,
mixins.AnonymousUserRequired,
DataLayerMixin,
WagtailCacheMixin,
Page,
):
# Note that this is was the original homepage for Magna/V2 MPV.
Expand All @@ -163,10 +161,6 @@ class DomesticHomePage(
ImageChooserPanel('image'),
]

# Deliberately asking wagtail not to cache homepage
def cache_control(self):
return 'no-cache'


class DomesticDashboard(
mixins.WagtailAdminExclusivePageMixin,
Expand Down
27 changes: 0 additions & 27 deletions tests/unit/domestic/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1804,30 +1804,3 @@ def test_allowed_parents(self):
GreatDomesticHomePage,
},
)


@pytest.mark.django_db
def test_great_domestic_homepage_header_cache(root_page, client, user):

homepage = GreatDomesticHomePageFactory(
parent=root_page,
slug='root',
)

SiteFactory(
root_page=homepage,
hostname=client._base_environ()['SERVER_NAME'],
)

for user_logged_in in (False, True):

if user_logged_in:
client.force_login(user)

response = client.get(homepage.url)

assert response.has_header('Cache-Control') is True
assert response.get('Cache-Control') == 'no-cache'

assert response.has_header('X-Wagtail-Cache') is True
assert response.get('X-Wagtail-Cache') == 'skip'

0 comments on commit e816425

Please sign in to comment.