Skip to content

Commit c8aeb68

Browse files
authored
Merge pull request #6887 from readthedocs/cf-purging
Add CloudFlare Cache tags support
2 parents 5b605e4 + 031735d commit c8aeb68

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-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
@@ -1837,6 +1837,7 @@ def _sync_imported_files(version, build, changed_files):
18371837
files_changed.send(
18381838
sender=Project,
18391839
project=version.project,
1840+
version=version,
18401841
files=changed_files,
18411842
)
18421843

readthedocs/proxito/views/mixins.py

+2
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ 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+
# Include the project & project-version so we can do larger purges if needed
130+
response['Cache-Tags'] = f'{final_project.slug}-{version_slug},{final_project.slug}'
129131
if hasattr(request, 'rtdheader'):
130132
response['X-RTD-Version-Method'] = 'rtdheader'
131133
if hasattr(request, 'subdomain'):

0 commit comments

Comments
 (0)