Skip to content

Commit 2a235cc

Browse files
committed
Add CloudFlare Cache tags support
This lets us purge the CDN more easily. This requires a version in the files_changed signal.
1 parent 4fded8c commit 2a235cc

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

readthedocs/projects/signals.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
project_import = django.dispatch.Signal(providing_args=['project'])
1313

1414
# Used to purge files from the CDN
15-
files_changed = django.dispatch.Signal(providing_args=['project', 'files'])
15+
files_changed = django.dispatch.Signal(providing_args=['project', 'version', 'files'])
1616

1717
# Used to force verify a domain (eg. for SSL cert issuance)
1818
domain_verify = django.dispatch.Signal(providing_args=['domain'])

readthedocs/projects/tasks.py

+1
Original file line numberDiff line numberDiff line change
@@ -1830,6 +1830,7 @@ def _sync_imported_files(version, build, changed_files):
18301830
files_changed.send(
18311831
sender=Project,
18321832
project=version.project,
1833+
version=version,
18331834
files=changed_files,
18341835
)
18351836

readthedocs/proxito/views/mixins.py

+1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ def _serve_docs_nginx(self, request, final_project, version_slug, path, download
126126
response['X-RTD-Version'] = version_slug
127127
# Needed to strip any GET args, etc.
128128
response['X-RTD-Path'] = urlparse(path).path
129+
response['Cache-Tags'] = f'{final_project.slug}-{version_slug}'
129130
if hasattr(request, 'rtdheader'):
130131
response['X-RTD-Version-Method'] = 'rtdheader'
131132
if hasattr(request, 'subdomain'):

0 commit comments

Comments
 (0)