@@ -71,6 +71,13 @@ class Endurance_Page_Cache {
71
71
*/
72
72
public $ cloudflare_tier = 'basic ' ;
73
73
74
+ /**
75
+ * File Based enabled
76
+ *
77
+ * @var bool
78
+ */
79
+ public $ file_based_enabled = false ;
80
+
74
81
/**
75
82
* Whether or not to force a purge.
76
83
*
@@ -166,6 +173,7 @@ public function __construct() {
166
173
$ this ->cloudflare_enabled = (bool ) $ cloudflare_state ;
167
174
$ this ->cloudflare_tier = ( is_numeric ( $ cloudflare_state ) && $ cloudflare_state ) ? 'basic ' : $ cloudflare_state ;
168
175
$ this ->udev_api_services ['cf ' ] = $ this ->cloudflare_tier ;
176
+ $ this ->file_based_enabled = (bool ) get_option ( 'endurance_file_enabled ' , false === strpos ( dirname ( __FILE__ ), 'public_html ' ) );
169
177
170
178
array_push ( $ this ->cache_exempt , rest_get_url_prefix () );
171
179
@@ -359,7 +367,7 @@ public function to_snake_case( $value, $delimiter = '_' ) {
359
367
* @return bool True if uses file system to cache
360
368
*/
361
369
public function use_file_cache () {
362
- return false === strpos ( dirname ( __FILE__ ), ' public_html ' ) ;
370
+ return $ this -> file_based_enabled ;
363
371
}
364
372
365
373
/**
@@ -1046,7 +1054,11 @@ public function htaccess_contents_rewrites( $rules ) {
1046
1054
$ base = wp_parse_url ( trailingslashit ( get_option ( 'home ' ) ), PHP_URL_PATH );
1047
1055
$ cache_url = $ base . str_replace ( get_option ( 'home ' ), '' , WP_CONTENT_URL . '/endurance-page-cache ' );
1048
1056
$ cache_url = str_replace ( '// ' , '/ ' , $ cache_url );
1049
- $ additions = "<ifModule mod_headers.c> \n" . 'Header set X-Endurance-Cache-Level " ' . $ this ->cache_level . '" ' . "\n</ifModule> \n" ;
1057
+ $ additions = "\n
1058
+ <ifModule mod_headers.c> \n" . '
1059
+ Header set X-Endurance-Cache-Level " ' . $ this ->cache_level . '" ' . "\n" . '
1060
+ Header set X-nginx-cache "WordPress" ' . "\n
1061
+ </ifModule> \n" ;
1050
1062
1051
1063
if ( $ this ->use_file_cache () ) {
1052
1064
$ additions .= 'Options -Indexes ' . "\n" . '
@@ -1081,7 +1093,7 @@ public function htaccess_contents_expirations( $rules ) {
1081
1093
'text/css ' => '1 month ' ,
1082
1094
'application/pdf ' => '1 month ' ,
1083
1095
'text/javascript ' => '1 month ' ,
1084
- 'text/html ' => '5 minutes ' ,
1096
+ 'text/html ' => '2 hours ' ,
1085
1097
);
1086
1098
1087
1099
$ file_types = wp_parse_args ( get_option ( 'epc_filetype_expirations ' , array () ), $ default_files );
@@ -1288,7 +1300,7 @@ public function update_level_expirations( $level ) {
1288
1300
'text/css ' => '1 week ' ,
1289
1301
'application/pdf ' => '1 week ' ,
1290
1302
'text/javascript ' => '1 month ' ,
1291
- 'text/html ' => '4 hours ' ,
1303
+ 'text/html ' => '8 hours ' ,
1292
1304
'default ' => '1 week ' ,
1293
1305
);
1294
1306
break ;
@@ -1302,7 +1314,7 @@ public function update_level_expirations( $level ) {
1302
1314
'text/css ' => '24 hours ' ,
1303
1315
'application/pdf ' => '1 week ' ,
1304
1316
'text/javascript ' => '24 hours ' ,
1305
- 'text/html ' => '5 minutes ' ,
1317
+ 'text/html ' => '2 hours ' ,
1306
1318
'default ' => '24 hours ' ,
1307
1319
);
1308
1320
break ;
0 commit comments