Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache filtered CSV downloads for one hour #4192

Merged
merged 6 commits into from
Jun 26, 2024
Merged

Cache filtered CSV downloads for one hour #4192

merged 6 commits into from
Jun 26, 2024

Conversation

paul-m
Copy link
Contributor

@paul-m paul-m commented Jun 6, 2024

The issue is that even if our infrastructure is set up to cache streaming CSV responses, DKAN tells it not to by defaulting to Cache-Control: private.

Luckily, we can use Drupal\common\CacheableResponseTrait to change the default on the existing controller, Drupal\datastore\Controller\QueryDownloadController. Setting a max age of one hour also tells this trait to use Cache-Control: public.

  • Fixes minor bug in Drupal\common\CacheableResponseTrait.
  • Leverages Drupal\common\CacheableResponseTrait to set max-age cache header to an hour.
  • Updates Drupal\Tests\datastore\Unit\Controller\QueryDownloadControllerTest to check for the cache header.
  • Updates other tests with @group so I can run them locally without running the whole test suite.

@paul-m paul-m marked this pull request as ready for review June 6, 2024 17:30
@paul-m paul-m requested a review from dafeder June 12, 2024 15:07
@dafeder dafeder self-assigned this Jun 12, 2024
Copy link
Member

@dafeder dafeder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note the new @todo in the code; this should really be parameterized; we shouldn't assume 1 hour is right for all use cases.

@dafeder dafeder merged commit 4193da7 into 2.x Jun 26, 2024
10 checks passed
@dafeder dafeder deleted the 20883-cache-csv branch June 26, 2024 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants