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

close #2058 invalidate cache for frequently use API #2059

Merged
merged 1 commit into from
Nov 20, 2024

Conversation

theachoem
Copy link
Collaborator

@theachoem theachoem commented Nov 18, 2024

In this PR:

  1. Invalidate cache
    image

  2. Set cache to header for GET or HEAD. eg. content.bookme.plus

Since we use MiniProfilerRails, we can't set cache control at all. It will override.

MiniProfilerRails MiniProfilerRails (I disabled it for test)
image image

Related PR:

@theachoem theachoem requested a review from channainfo November 18, 2024 19:17
@theachoem theachoem self-assigned this Nov 18, 2024
@theachoem theachoem force-pushed the 2058-invalidate-cache-for-frequently-use-api branch from 1862001 to 92c2dad Compare November 19, 2024 07:12
@theachoem theachoem linked an issue Nov 19, 2024 that may be closed by this pull request
@theachoem theachoem force-pushed the 2058-invalidate-cache-for-frequently-use-api branch 5 times, most recently from 12ffaf0 to 121421e Compare November 19, 2024 08:44
return unless request.get? || request.head?
return unless request.base_url == ENV['CONTENT_HOST_URL']

response.set_header('Cache-Control', 'public, max-age=7200')
Copy link
Owner

Choose a reason for hiding this comment

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

Let's make the 7200 in a ENV['CACHE_MAX_AGE']. and default it to 7200 if it does not exist.

@theachoem theachoem force-pushed the 2058-invalidate-cache-for-frequently-use-api branch from 121421e to 0e39a3a Compare November 19, 2024 09:24
@theachoem theachoem force-pushed the 2058-invalidate-cache-for-frequently-use-api branch from 0e39a3a to dbc9981 Compare November 19, 2024 09:29
@channainfo channainfo merged commit fe5aca0 into develop Nov 20, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Invalidate cache for frequently used API
2 participants