We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4ea4b4e commit 0bb377cCopy full SHA for 0bb377c
app/controllers/api_public/v1/base_controller.rb
@@ -2,7 +2,22 @@ module ApiPublic
2
module V1
3
class BaseController < ActionController::Base
4
include SubdomainTenant
5
+
6
skip_before_action :verify_authenticity_token
7
8
+ # Set HTTP cache headers and conditional GET for all api_public endpoints
9
+ before_action :set_api_public_cache_headers
10
11
+ private
12
13
+ def set_api_public_cache_headers
14
+ expires_in 5.hours, public: true
15
+ # Conditional GET: Use a generic last-modified time (can be overridden in child controllers)
16
+ return unless respond_to?(:resource_last_modified, true)
17
18
+ last_modified = resource_last_modified
19
+ fresh_when(last_modified: last_modified) if last_modified
20
+ end
21
end
22
23
0 commit comments