spree_cm_commissioner 2.5.3 → 2.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7d93944d0194c1c575eca6f946b9b616ba4772fba61151fbc9b605464d87cb46
|
|
4
|
+
data.tar.gz: a0f1f687982be229cf5958a5f0ba0077eac693166dde8587c9a69df8bbf6caae
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 978c11238f4ba63ff0e9e41444ca8d67046eab18d924996ad03dd4c64fe725285f225db7a9f8345220e60cb91b4147f915b8096eefc40c15453f2a090e115000
|
|
7
|
+
data.tar.gz: 9256c928528ebd0911aa5c4083ce477821d5117cfa379d205f8667fcbca17bd5e5f2052839d67079bf5627a4a56747f0e45d4ccb236c97831c6de6bdf45fec81
|
data/Gemfile.lock
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# Check following file for spec:
|
|
2
|
+
# spec/controllers/application_controller_spec.rb
|
|
1
3
|
module SpreeCmCommissioner
|
|
2
4
|
module ContentCachable
|
|
3
5
|
extend ActiveSupport::Concern
|
|
@@ -6,9 +8,64 @@ module SpreeCmCommissioner
|
|
|
6
8
|
after_action :set_cache_control_for_cdn
|
|
7
9
|
end
|
|
8
10
|
|
|
11
|
+
# Cache duration priorities by content type
|
|
12
|
+
# Priority 1: Static/Rarely Changed (1 day)
|
|
13
|
+
STATIC_CONTENT_CONTROLLERS = %w[
|
|
14
|
+
CountriesController
|
|
15
|
+
ProvincesController
|
|
16
|
+
GuestCardClassesController
|
|
17
|
+
SeatLayoutController
|
|
18
|
+
CmsPagesController
|
|
19
|
+
].freeze
|
|
20
|
+
|
|
21
|
+
# Priority 2: Semi-Static (1 hour)
|
|
22
|
+
SEMI_STATIC_CONTROLLERS = %w[
|
|
23
|
+
MenusController
|
|
24
|
+
HomepageBackgroundController
|
|
25
|
+
HomepageDataController
|
|
26
|
+
PopularRoutesController
|
|
27
|
+
RoutePlacesController
|
|
28
|
+
].freeze
|
|
29
|
+
|
|
30
|
+
# Priority 3: Moderate Freshness (30 minutes)
|
|
31
|
+
MODERATE_FRESHNESS_CONTROLLERS = %w[
|
|
32
|
+
HomepageSectionsController
|
|
33
|
+
TaxonsController
|
|
34
|
+
ProductsController
|
|
35
|
+
EventsController
|
|
36
|
+
EventMatchesController
|
|
37
|
+
AccommodationsController
|
|
38
|
+
VendorsController
|
|
39
|
+
VendorPhotosController
|
|
40
|
+
DynamicFieldsController
|
|
41
|
+
].freeze
|
|
42
|
+
|
|
43
|
+
# Priority 4: High Freshness (5 minutes)
|
|
44
|
+
HIGH_FRESHNESS_CONTROLLERS = %w[
|
|
45
|
+
TripsController
|
|
46
|
+
TripSearchController
|
|
47
|
+
].freeze
|
|
48
|
+
|
|
49
|
+
def shared_max_age
|
|
50
|
+
ENV.fetch('CACHE_CDN_MAX_AGE', 1.day.to_i).to_i
|
|
51
|
+
end
|
|
52
|
+
|
|
9
53
|
# Override This Method based on your UseCase
|
|
10
|
-
|
|
11
|
-
|
|
54
|
+
# Or let it auto-detect based on controller name
|
|
55
|
+
def client_max_age
|
|
56
|
+
controller_name = self.class.name.demodulize
|
|
57
|
+
|
|
58
|
+
if STATIC_CONTENT_CONTROLLERS.include?(controller_name)
|
|
59
|
+
ENV.fetch('CACHE_STATIC_MAX_AGE', 1.day.to_i).to_i
|
|
60
|
+
elsif SEMI_STATIC_CONTROLLERS.include?(controller_name)
|
|
61
|
+
ENV.fetch('CACHE_SEMI_STATIC_MAX_AGE', 1.hour.to_i).to_i
|
|
62
|
+
elsif MODERATE_FRESHNESS_CONTROLLERS.include?(controller_name)
|
|
63
|
+
ENV.fetch('CACHE_MODERATE_MAX_AGE', 30.minutes.to_i).to_i
|
|
64
|
+
elsif HIGH_FRESHNESS_CONTROLLERS.include?(controller_name)
|
|
65
|
+
ENV.fetch('CACHE_REALTIME_MAX_AGE', 5.minutes.to_i).to_i
|
|
66
|
+
else
|
|
67
|
+
ENV.fetch('CACHE_DEFAULT_MAX_AGE', 5.minutes.to_i).to_i
|
|
68
|
+
end
|
|
12
69
|
end
|
|
13
70
|
|
|
14
71
|
def set_cache_control_for_cdn
|
|
@@ -17,12 +74,7 @@ module SpreeCmCommissioner
|
|
|
17
74
|
|
|
18
75
|
# max-age: browser/client cache, s-maxage: CDN/server cache
|
|
19
76
|
# Allow client caching for mobile apps while keeping CDN cache longer
|
|
20
|
-
|
|
21
|
-
response.headers['Cache-Control'] = "public, max-age=#{client_max_age}, s-maxage=#{max_age}"
|
|
22
|
-
|
|
23
|
-
# Pragma: HTTP/1.0 cache directive (predates Cache-Control).
|
|
24
|
-
# 'cache' allows caching.
|
|
25
|
-
response.headers['Pragma'] = 'cache'
|
|
77
|
+
response.headers['Cache-Control'] = "public, max-age=#{client_max_age}, s-maxage=#{shared_max_age}"
|
|
26
78
|
|
|
27
79
|
# Expires: Absolute timestamp when cache becomes stale (HTTP/1.0 fallback)
|
|
28
80
|
response.headers['Expires'] = (Time.zone.now + client_max_age).httpdate
|