Skip to content

Commit

Permalink
Do not convert cache duration to hours
Browse files Browse the repository at this point in the history
Hours is not fine enough as granularity for good cache control. For this
reason, the `Cache-Control` header operates with a granularity of
seconds as well. Let's also work with seconds here.

This is literally a breaking change, but it will only break caches.
  • Loading branch information
mamhoff committed May 15, 2024
1 parent 7b1d334 commit 2a0d06b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/alchemy/json_api/nodes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def index
private

def cache_duration
ENV.fetch("ALCHEMY_JSON_API_CACHE_DURATION", 3).to_i.hours
ENV.fetch("ALCHEMY_JSON_API_CACHE_DURATION", 3).to_i
end

def jsonapi_meta(nodes)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/alchemy/json_api/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def render_pages_json(allowed)
end

def cache_duration
ENV.fetch("ALCHEMY_JSON_API_CACHE_DURATION", 3).to_i.hours
ENV.fetch("ALCHEMY_JSON_API_CACHE_DURATION", 3).to_i
end

def caching_options
Expand Down

0 comments on commit 2a0d06b

Please sign in to comment.