Skip to content

Commit

Permalink
add a postdeploy step to purge surroage-keys for static files
Browse files Browse the repository at this point in the history
  • Loading branch information
ewdurbin committed Sep 25, 2024
1 parent 107f838 commit 4729534
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ release: python manage.py migrate --noinput
web: bin/start-nginx gunicorn -c gunicorn.conf pydotorg.wsgi
worker: celery -A pydotorg worker -l INFO
worker-beat: celery -A pydotorg beat -l INFO --scheduler django_celery_beat.schedulers:DatabaseScheduler
postdeploy: python manage.py postdeploy
Empty file added pydotorg/management/__init__.py
Empty file.
Empty file.
14 changes: 14 additions & 0 deletions pydotorg/management/commands/postdeploy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from django.core.management.base import BaseCommand
from django.conf import settings

from fastly.utils import purge_surrogate_key


class Command(BaseCommand):
""" Do things after deployment is complete """

def handle(self, *args, **kwargs):
# If we have a STATIC_SURROGATE_KEY set, purge static files to ensure
# that anything cached mid-deploy is ignored (like 404s).
if settings.STATIC_SURROGATE_KEY:
purge_surrogate_key(settings.STATIC_SURROGATE_KEY)

0 comments on commit 4729534

Please sign in to comment.