@@ -111,9 +111,35 @@ function setup_scss_folders() {
111
111
}
112
112
113
113
/**
114
- * Register and selectively enqueue the scripts and stylesheets needed for this
115
- * page.
114
+ * Override max cache age for certain conditions.
115
+ *
116
+ * The default cache behavior is defined by the combination of two plugins:
117
+ * Pantheon MU Plugin and Pantheon Advanced Page Cache. The cache lifetime is
118
+ * typically set to 1 week via the former plugin, but certain pages require a
119
+ * shorter cache life. This function implements those alternative lifetimes.
120
+ *
121
+ * @link https://docs.pantheon.io/guides/wordpress-configurations/wordpress-cache-plugin#override-the-default-max-age
116
122
*/
123
+ function override_cache_default_max_age () {
124
+ $ site = parse_url ( get_site_url (), PHP_URL_PATH );
125
+ if ( is_page ( 'hours ' ) ) { // All hours pages (including those with query parameters).
126
+ return 1 * DAY_IN_SECONDS ;
127
+ } elseif ( '/news ' == $ site && is_page ( 'events ' ) ) { // The news site events page.
128
+ return 1 * DAY_IN_SECONDS ;
129
+ } elseif ( '/exhibits ' == $ site && is_page ( '' ) ) { // The exhibits site homepage.
130
+ return 1 * DAY_IN_SECONDS ;
131
+ } elseif ( '/exhibits ' == $ site && is_page ( 'current-upcoming-past-exhibits ' ) ) { // The exhibits site composite listing.
132
+ return 1 * DAY_IN_SECONDS ;
133
+ } else { // All other content should be cached for a week.
134
+ return 1 * WEEK_IN_SECONDS ;
135
+ }
136
+ }
137
+ add_filter ( 'pantheon_cache_default_max_age ' , 'Mitlib\Parent\override_cache_default_max_age ' );
138
+
139
+ /**
140
+ * Register and selectively enqueue the scripts and stylesheets needed for this
141
+ * page.
142
+ */
117
143
function setup_scripts_styles () {
118
144
// This allows us to cache-bust these assets without needing to remember to
119
145
// increment the theme version here.
0 commit comments