Skip to content

Add conditional-request support to PyPI metadata APIs - #1341

Merged
jobselko merged 1 commit into
pulp:mainfrom
dkliban:1338-conditional-requests
Aug 26, 2026
Merged

Add conditional-request support to PyPI metadata APIs#1341
jobselko merged 1 commit into
pulp:mainfrom
dkliban:1338-conditional-requests

Conversation

@dkliban

@dkliban dkliban commented Aug 20, 2026

Copy link
Copy Markdown
Member

Summary

Add Last-Modified / If-Modified-Since conditional request support to the Simple API and JSON Metadata API for improved cache efficiency. Also adds ETag, Cache-Control, and If-None-Match support to the JSON Metadata API which previously had none.

Changes:

  • Extract _get_repo_version() helper to share repo version resolution between _etag_func and new _last_modified_func
  • Add last_modified_func=_last_modified_func to @condition decorators on SimpleView.list and SimpleView.retrieve
  • Add @condition(etag_func=_etag_func, last_modified_func=_last_modified_func) and @cache_control(max_age=900, public=True) to MetadataView.retrieve

Security: Authorization is checked before conditional request handling because DRF's initial() (permissions) runs before the view method where @condition operates.

Closes: #1338

Test plan

  • test_simple_last_modified_header — Last-Modified present on Simple API responses
  • test_simple_if_modified_since_304 — If-Modified-Since with matching timestamp returns 304
  • test_simple_if_modified_since_old_timestamp_200 — old timestamp returns 200
  • test_metadata_conditional_request_headers — ETag, Last-Modified, Cache-Control on metadata
  • test_metadata_etag_conditional_request — If-None-Match 304/200
  • test_metadata_if_modified_since_304 — If-Modified-Since 304
  • test_metadata_if_modified_since_old_timestamp_200 — old timestamp returns 200
  • test_unauthenticated_gets_401_not_304 — unauthenticated client gets 401, not 304, with conditional headers
  • All 4 existing cache tests still pass

@jobselko

Copy link
Copy Markdown
Member

@dkliban Please tag me as a reviewer once this is ready (maybe it already is?)

@dkliban
dkliban requested a review from jobselko August 20, 2026 17:16
Comment thread pulp_python/tests/functional/api/test_simple_cache.py
Comment thread pulp_python/app/pypi/views.py
Comment thread CHANGES/1338.feature Outdated
@github-actions github-actions Bot added the multi-commit Add to bypass single commit lint check label Aug 21, 2026
@dkliban
dkliban force-pushed the 1338-conditional-requests branch from 9f0ef76 to e842c0a Compare August 21, 2026 19:19
@github-actions github-actions Bot removed the multi-commit Add to bypass single commit lint check label Aug 21, 2026
@dkliban
dkliban force-pushed the 1338-conditional-requests branch 2 times, most recently from b9dd8ef to 654357a Compare August 25, 2026 12:46
Comment thread pulp_python/tests/functional/api/test_simple_cache.py Outdated
Comment thread pulp_python/tests/functional/api/test_simple_cache.py Outdated
Add Last-Modified header and If-Modified-Since handling to SimpleView
and MetadataView for Akamai Centralized Authorization. Add ETag,
Cache-Control, and conditional request support to MetadataView which
previously had none.

Closes: pulp#1338
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dkliban
dkliban force-pushed the 1338-conditional-requests branch from 654357a to fca5bbc Compare August 25, 2026 16:12
@jobselko
jobselko merged commit a227ea6 into pulp:main Aug 26, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add conditional-request support (ETag + Last-Modified) to PyPI metadata APIs for Akamai Centralized Authorization

2 participants