LiteSpeed Cache - Version 2.2

Version Description

  • Apr 2 2018 =
  • [NEW FEATURE] Debug Disable All Features setting in Debug tab. (@monarobase)
  • [NEW FEATURE] Cache Force Cacheable URIs setting in Excludes tab.
  • [NEW FEATURE] Purge Purge all LSCache and other caches in one link.
  • [REFACTOR] Purge Refactored Purge class.
  • [BUGFIX] Query strings in DoNotCacheURI setting now works.
  • [BUGFIX] Cache Mobile cache compatibility with WebP vary. (@Shivam #987121)
  • [UPDATE] Purge Moved purge_all to Purge class from core class.
  • [API] Set cacheable/Set force cacheable. (@Jacob)
Download this release

Release Info

Developer LiteSpeedTech
Plugin Icon 128x128 LiteSpeed Cache
Version 2.2
Comparing to
See all releases

Code changes from version 2.1.2 to 2.2

admin/litespeed-cache-admin-settings.class.php CHANGED
@@ -55,7 +55,7 @@ class LiteSpeed_Cache_Admin_Settings
55
  */
56
  public function validate_plugin_settings( $input )
57
  {
58
- LiteSpeed_Cache_Log::debug( 'Settings: validate_plugin_settings called' ) ;
59
  $this->_options = LiteSpeed_Cache_Config::get_instance()->get_options() ;
60
 
61
  if ( LiteSpeed_Cache_Admin_Display::get_instance()->get_disable_all() ) {
@@ -98,7 +98,7 @@ class LiteSpeed_Cache_Admin_Settings
98
  $new_esi_enabled = $this->_options[ LiteSpeed_Cache_Config::OPID_ESI_ENABLE ] ;
99
 
100
  if ( $orig_esi_enabled !== $new_esi_enabled ) {
101
- LiteSpeed_Cache_Purge::purge_all() ;
102
  }
103
  }
104
 
@@ -194,7 +194,7 @@ class LiteSpeed_Cache_Admin_Settings
194
  }
195
  }
196
  else {
197
- LiteSpeed_Cache_Purge::purge_all() ;
198
  }
199
  }
200
 
@@ -202,7 +202,7 @@ class LiteSpeed_Cache_Admin_Settings
202
  $orig_primary = $options[ $id ] ;
203
  $options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
204
  if ( $orig_primary != $options[ $id ] ) {
205
- LiteSpeed_Cache_Purge::purge_all() ;
206
  }
207
 
208
  $id = LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE ;
@@ -295,20 +295,22 @@ class LiteSpeed_Cache_Admin_Settings
295
  /**
296
  * Check if object cache file existing or not
297
  */
298
- $id = LiteSpeed_Cache_Config::OPID_CACHE_OBJECT ;
299
- if ( $new_options[ $id ] ) {
300
- $all_options = array_merge( $new_options, $item_options ) ;
301
- LiteSpeed_Cache_Log::debug( 'Settings: Update .object_cache.ini and flush object cache' ) ;
302
- LiteSpeed_Cache_Object::get_instance()->update_file( true, $all_options ) ;
303
- /**
304
- * Clear object cache
305
- */
306
- LiteSpeed_Cache_Object::get_instance()->reconnect( $all_options ) ;
307
- }
308
- else {
309
- if ( defined( 'LSCWP_OBJECT_CACHE' ) ) {
310
- LiteSpeed_Cache_Log::debug( 'Settings: Remove .object_cache.ini' ) ;
311
- LiteSpeed_Cache_Object::get_instance()->update_file( false ) ;
 
 
312
  }
313
  }
314
 
@@ -336,7 +338,7 @@ class LiteSpeed_Cache_Admin_Settings
336
 
337
  // Purge when disabled
338
  if ( ! $enabled ) {
339
- LiteSpeed_Cache_Purge::purge_all() ;
340
  ! defined( 'LITESPEED_NEW_OFF' ) && define( 'LITESPEED_NEW_OFF', true ) ; // Latest status is off
341
  }
342
  else {
@@ -469,6 +471,11 @@ class LiteSpeed_Cache_Admin_Settings
469
  */
470
  private function _validate_exclude()
471
  {
 
 
 
 
 
472
  $id = LiteSpeed_Cache_Config::OPID_EXCLUDES_URI ;
473
  if ( isset( $this->_input[ $id ] ) ) {
474
  $this->_options[ $id ] = LiteSpeed_Cache_Utility::sanitize_lines( $this->_input[ $id ], 'relative' ) ;
@@ -660,7 +667,7 @@ class LiteSpeed_Cache_Admin_Settings
660
  }
661
  else {
662
  $this->_options[ LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_ZONE ] = '' ;
663
- LiteSpeed_Cache_Log::debug( 'Settings: Get zone failed, clean zone' ) ;
664
  }
665
  }
666
  }
@@ -800,16 +807,16 @@ class LiteSpeed_Cache_Admin_Settings
800
  // if ( ! empty( $_FILES[ 'litespeed-file-favicon_' . $v ][ 'name' ] ) ) {
801
  // $file = wp_handle_upload( $_FILES[ 'litespeed-file-favicon_' . $v ], array( 'action' => 'update' ) ) ;
802
  // if ( ! empty( $file[ 'url' ] ) ) {
803
- // LiteSpeed_Cache_Log::debug( 'Settings: Updated favicon [' . $v . '] ' . $file[ 'url' ] ) ;
804
 
805
  // $new_favicons[ $v ] = $file[ 'url' ] ;
806
 
807
  // }
808
  // elseif ( isset( $file[ 'error' ] ) ) {
809
- // LiteSpeed_Cache_Log::debug( 'Settings: Failed to update favicon: [' . $v . '] ' . $file[ 'error' ] ) ;
810
  // }
811
  // else {
812
- // LiteSpeed_Cache_Log::debug( 'Settings: Failed to update favicon: Unkown err [' . $v . ']' ) ;
813
  // }
814
  // }
815
  // }
@@ -863,6 +870,7 @@ class LiteSpeed_Cache_Admin_Settings
863
  }
864
 
865
  $ids = array(
 
866
  LiteSpeed_Cache_Config::OPID_DEBUG_LEVEL,
867
  LiteSpeed_Cache_Config::OPID_HEARTBEAT,
868
  LiteSpeed_Cache_Config::OPID_DEBUG_COOKIE,
@@ -873,6 +881,13 @@ class LiteSpeed_Cache_Admin_Settings
873
  $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
874
  }
875
 
 
 
 
 
 
 
 
876
  // Filters ignored
877
  $ids = array(
878
  LiteSpeed_Cache_Config::ITEM_LOG_IGNORE_FILTERS,
@@ -1166,13 +1181,13 @@ class LiteSpeed_Cache_Admin_Settings
1166
  $instance[ LiteSpeed_Cache_Config::OPTION_NAME ][ LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ] = $ttl ;
1167
 
1168
  if ( ! $current || $esi != $current[ LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ] ) {
1169
- LiteSpeed_Cache_Purge::purge_all() ;
1170
  }
1171
  elseif ( $ttl != 0 && $ttl != $current[ LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ] ) {
1172
  LiteSpeed_Cache_Purge::add( LiteSpeed_Cache_Tag::TYPE_WIDGET . $widget->id ) ;
1173
  }
1174
 
1175
- LiteSpeed_Cache_Purge::purge_all() ;
1176
  return $instance ;
1177
  }
1178
 
55
  */
56
  public function validate_plugin_settings( $input )
57
  {
58
+ LiteSpeed_Cache_Log::debug( '[Settings] validate_plugin_settings called' ) ;
59
  $this->_options = LiteSpeed_Cache_Config::get_instance()->get_options() ;
60
 
61
  if ( LiteSpeed_Cache_Admin_Display::get_instance()->get_disable_all() ) {
98
  $new_esi_enabled = $this->_options[ LiteSpeed_Cache_Config::OPID_ESI_ENABLE ] ;
99
 
100
  if ( $orig_esi_enabled !== $new_esi_enabled ) {
101
+ LiteSpeed_Cache_Purge::purge_all( 'ESI changed' ) ;
102
  }
103
  }
104
 
194
  }
195
  }
196
  else {
197
+ LiteSpeed_Cache_Purge::purge_all( 'Network enable changed' ) ;
198
  }
199
  }
200
 
202
  $orig_primary = $options[ $id ] ;
203
  $options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
204
  if ( $orig_primary != $options[ $id ] ) {
205
+ LiteSpeed_Cache_Purge::purge_all( 'Network use_primary changed' ) ;
206
  }
207
 
208
  $id = LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE ;
295
  /**
296
  * Check if object cache file existing or not
297
  */
298
+ if ( ! defined( 'LITESPEED_DISABLE_OBJECT' ) ) {
299
+ $id = LiteSpeed_Cache_Config::OPID_CACHE_OBJECT ;
300
+ if ( $new_options[ $id ] ) {
301
+ $all_options = array_merge( $new_options, $item_options ) ;
302
+ LiteSpeed_Cache_Log::debug( '[Settings] Update .object_cache.ini and flush object cache' ) ;
303
+ LiteSpeed_Cache_Object::get_instance()->update_file( true, $all_options ) ;
304
+ /**
305
+ * Clear object cache
306
+ */
307
+ LiteSpeed_Cache_Object::get_instance()->reconnect( $all_options ) ;
308
+ }
309
+ else {
310
+ if ( defined( 'LSCWP_OBJECT_CACHE' ) ) {
311
+ LiteSpeed_Cache_Log::debug( '[Settings] Remove .object_cache.ini' ) ;
312
+ LiteSpeed_Cache_Object::get_instance()->update_file( false ) ;
313
+ }
314
  }
315
  }
316
 
338
 
339
  // Purge when disabled
340
  if ( ! $enabled ) {
341
+ LiteSpeed_Cache_Purge::purge_all( 'Not enabled' ) ;
342
  ! defined( 'LITESPEED_NEW_OFF' ) && define( 'LITESPEED_NEW_OFF', true ) ; // Latest status is off
343
  }
344
  else {
471
  */
472
  private function _validate_exclude()
473
  {
474
+ $id = LiteSpeed_Cache_Config::OPID_FORCE_CACHE_URI ;
475
+ if ( isset( $this->_input[ $id ] ) ) {
476
+ $this->_options[ $id ] = LiteSpeed_Cache_Utility::sanitize_lines( $this->_input[ $id ], 'relative' ) ;
477
+ }
478
+
479
  $id = LiteSpeed_Cache_Config::OPID_EXCLUDES_URI ;
480
  if ( isset( $this->_input[ $id ] ) ) {
481
  $this->_options[ $id ] = LiteSpeed_Cache_Utility::sanitize_lines( $this->_input[ $id ], 'relative' ) ;
667
  }
668
  else {
669
  $this->_options[ LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_ZONE ] = '' ;
670
+ LiteSpeed_Cache_Log::debug( '[Settings] Get zone failed, clean zone' ) ;
671
  }
672
  }
673
  }
807
  // if ( ! empty( $_FILES[ 'litespeed-file-favicon_' . $v ][ 'name' ] ) ) {
808
  // $file = wp_handle_upload( $_FILES[ 'litespeed-file-favicon_' . $v ], array( 'action' => 'update' ) ) ;
809
  // if ( ! empty( $file[ 'url' ] ) ) {
810
+ // LiteSpeed_Cache_Log::debug( '[Settings] Updated favicon [' . $v . '] ' . $file[ 'url' ] ) ;
811
 
812
  // $new_favicons[ $v ] = $file[ 'url' ] ;
813
 
814
  // }
815
  // elseif ( isset( $file[ 'error' ] ) ) {
816
+ // LiteSpeed_Cache_Log::debug( '[Settings] Failed to update favicon: [' . $v . '] ' . $file[ 'error' ] ) ;
817
  // }
818
  // else {
819
+ // LiteSpeed_Cache_Log::debug( '[Settings] Failed to update favicon: Unkown err [' . $v . ']' ) ;
820
  // }
821
  // }
822
  // }
870
  }
871
 
872
  $ids = array(
873
+ LiteSpeed_Cache_Config::OPID_DEBUG_DISABLE_ALL,
874
  LiteSpeed_Cache_Config::OPID_DEBUG_LEVEL,
875
  LiteSpeed_Cache_Config::OPID_HEARTBEAT,
876
  LiteSpeed_Cache_Config::OPID_DEBUG_COOKIE,
881
  $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
882
  }
883
 
884
+ // Remove Object Cache
885
+ if ( $this->_options[ LiteSpeed_Cache_Config::OPID_DEBUG_DISABLE_ALL ] ) {
886
+ LiteSpeed_Cache_Log::debug( '[Settings] Remove .object_cache.ini due to debug_disable_all' ) ;
887
+ LiteSpeed_Cache_Object::get_instance()->update_file( false ) ;
888
+ define( 'LITESPEED_DISABLE_OBJECT', true ) ;
889
+ }
890
+
891
  // Filters ignored
892
  $ids = array(
893
  LiteSpeed_Cache_Config::ITEM_LOG_IGNORE_FILTERS,
1181
  $instance[ LiteSpeed_Cache_Config::OPTION_NAME ][ LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ] = $ttl ;
1182
 
1183
  if ( ! $current || $esi != $current[ LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ] ) {
1184
+ LiteSpeed_Cache_Purge::purge_all( 'Wdiget ESI_enable changed' ) ;
1185
  }
1186
  elseif ( $ttl != 0 && $ttl != $current[ LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ] ) {
1187
  LiteSpeed_Cache_Purge::add( LiteSpeed_Cache_Tag::TYPE_WIDGET . $widget->id ) ;
1188
  }
1189
 
1190
+ LiteSpeed_Cache_Purge::purge_all( 'Wdiget saved' ) ;
1191
  return $instance ;
1192
  }
1193
 
admin/tpl/edit_htaccess.php CHANGED
@@ -7,7 +7,6 @@ $htaccess_path = LiteSpeed_Cache_Admin_Rules::get_frontend_htaccess() ;
7
 
8
  // Check if there is `ExpiresDefault` in .htaccess
9
  if ( defined( 'LITESPEED_ON' ) ) {
10
- $htaccess_con = Litespeed_File::read( LiteSpeed_Cache_Admin_Rules::get_frontend_htaccess() ) ;
11
  if ( $content && stripos( $content, "\nExpiresDefault" ) !== false ) {
12
  $is_dismissed = get_option( self::DISMISS_MSG ) ;
13
  if ( $is_dismissed !== self::RULECONFLICT_DISMISSED ) {
7
 
8
  // Check if there is `ExpiresDefault` in .htaccess
9
  if ( defined( 'LITESPEED_ON' ) ) {
 
10
  if ( $content && stripos( $content, "\nExpiresDefault" ) !== false ) {
11
  $is_dismissed = get_option( self::DISMISS_MSG ) ;
12
  if ( $is_dismissed !== self::RULECONFLICT_DISMISSED ) {
admin/tpl/manage/manage_purge.php CHANGED
@@ -6,71 +6,76 @@ $_panels = array(
6
  array(
7
  'title' => __( 'Purge Front Page', 'litespeed-cache' ),
8
  'desc' => __( 'This will Purge Front Page only', 'litespeed-cache' ),
9
- 'tag' => LiteSpeed_Cache::ACTION_PURGE_FRONT,
10
  'icon' => 'purge-front',
 
11
  ),
12
  array(
13
  'title' => __( 'Purge Pages', 'litespeed-cache' ),
14
  'desc' => __( 'This will Purge Pages only', 'litespeed-cache' ),
15
- 'tag' => LiteSpeed_Cache::ACTION_PURGE_PAGES,
16
  'icon' => 'purge-pages',
 
17
  ),
18
  array(
19
- 'title' => __( 'Purge CSS/JS Cache', 'litespeed-cache' ),
20
- 'desc' => __( 'This will purge all minified/combined CSS/JS entries only', 'litespeed-cache' ),
21
- 'tag' => LiteSpeed_Cache::ACTION_PURGE_CSSJS,
22
- 'icon' => 'purge-cssjs',
23
- ),
24
- array(
25
- 'title' => __( 'Purge 403 Error', 'litespeed-cache' ),
26
- 'desc' => __( 'Purge error pages, including 403 pages', 'litespeed-cache' ),
27
- 'tag' => LiteSpeed_Cache::ACTION_PURGE_ERRORS,
28
  'icon' => 'purge-403',
29
- 'append_url' => '403',
30
  ),
31
  array(
32
- 'title' => __( 'Purge 404 Error', 'litespeed-cache' ),
33
- 'desc' => __( 'Purge error pages, including 404 pages', 'litespeed-cache' ),
34
- 'tag' => LiteSpeed_Cache::ACTION_PURGE_ERRORS,
35
  'icon' => 'purge-404',
36
- 'append_url' => '404',
37
  ),
38
  array(
 
 
39
  'title' => __( 'Purge 500 Error', 'litespeed-cache' ),
40
  'desc' => __( 'Purge error pages, including 500 pages', 'litespeed-cache' ),
41
- 'tag' => LiteSpeed_Cache::ACTION_PURGE_ERRORS,
42
  'icon' => 'purge-500',
43
- 'append_url' => '500',
44
  ),
45
  array(
46
- 'title' => __( 'Purge All', 'litespeed-cache' ),
47
- 'desc' => __( 'Purge the cache entries created by this plugin', 'litespeed-cache' ),
48
- 'tag' => LiteSpeed_Cache::ACTION_PURGE_ALL,
49
  'icon' => 'purge-all',
50
- 'title_cls' => 'litespeed-warning',
 
 
 
 
 
 
51
  ),
52
  ) ;
53
 
54
  if ( defined( 'LSCWP_OBJECT_CACHE' ) ) {
55
  $_panels[] = array(
56
- 'title' => __( 'Object Cache Purge All', 'litespeed-cache' ),
57
  'desc' => __( 'Purge all the object caches', 'litespeed-cache' ),
58
- 'tag' => LiteSpeed_Cache::ACTION_PURGE,
59
  'icon' => 'purge-object',
60
- 'append_url' => LiteSpeed_Cache_Purge::TYPE_OBJECT_PURGE_ALL,
61
  ) ;
62
  }
63
 
64
  if ( LiteSpeed_Cache_Router::opcache_enabled() ) {
65
  $_panels[] = array(
66
- 'title' => __( 'Opcode Cache Purge All', 'litespeed-cache' ),
67
  'desc' => __( 'Reset the entire opcode cache', 'litespeed-cache' ),
68
- 'tag' => LiteSpeed_Cache::ACTION_PURGE,
69
  'icon' => 'purge-opcache',
70
- 'append_url' => LiteSpeed_Cache_Purge::TYPE_OPCACHE_PURGE_ALL,
71
  ) ;
72
  }
73
 
 
 
 
 
 
 
 
 
 
74
  if ( ! is_multisite() || is_network_admin() ) {
75
  $_panels[] = array(
76
  'title' => __( 'Empty Entire Cache', 'litespeed-cache' ),
@@ -79,7 +84,6 @@ if ( ! is_multisite() || is_network_admin() ) {
79
  'tag' => LiteSpeed_Cache::ACTION_PURGE_EMPTYCACHE,
80
  'icon' => 'empty-cache',
81
  'title_cls' => 'litespeed-danger',
82
- 'newline' => true,
83
  'cfm' => esc_html( __( 'This will clear EVERYTHING inside the cache.', 'litespeed-cache' ) ) . ' ' .
84
  esc_html( __( 'This may cause heavy load on the server.', 'litespeed-cache' ) ) . ' ' .
85
  esc_html( __( 'If only the WordPress site should be purged, use purge all.', 'litespeed-cache' ) )
@@ -95,13 +99,15 @@ if ( ! is_multisite() || is_network_admin() ) {
95
  <div class="litespeed-panel-wrapper">
96
 
97
  <?php foreach ( $_panels as $v ): ?>
 
 
98
 
99
  <?php if ( ! empty( $v[ 'newline' ] ) ) : ?>
100
  <div class='litespeed-col-br'></div>
101
  <?php endif; ?>
102
 
103
  <a class="litespeed-panel"
104
- href="<?php echo LiteSpeed_Cache_Utility::build_url( $v[ 'tag' ], ! empty( $v[ 'append_url' ] ) ? $v[ 'append_url' ] : false ) ; ?>"
105
  <?php if ( ! empty( $v[ 'cfm' ] ) ) echo 'data-litespeed-cfm="' . $v[ 'cfm' ] . '"' ; ?>
106
  >
107
  <section class="litespeed-panel-wrapper-icon">
6
  array(
7
  'title' => __( 'Purge Front Page', 'litespeed-cache' ),
8
  'desc' => __( 'This will Purge Front Page only', 'litespeed-cache' ),
 
9
  'icon' => 'purge-front',
10
+ 'append_url' => LiteSpeed_Cache_Purge::TYPE_PURGE_FRONTPAGE,
11
  ),
12
  array(
13
  'title' => __( 'Purge Pages', 'litespeed-cache' ),
14
  'desc' => __( 'This will Purge Pages only', 'litespeed-cache' ),
 
15
  'icon' => 'purge-pages',
16
+ 'append_url' => LiteSpeed_Cache_Purge::TYPE_PURGE_PAGES,
17
  ),
18
  array(
19
+ 'title' => sprintf( __( 'Purge %s Error', 'litespeed-cache' ), '403' ),
20
+ 'desc' => sprintf( __( 'Purge error pages, including %s pages', 'litespeed-cache' ), '403' ),
 
 
 
 
 
 
 
21
  'icon' => 'purge-403',
22
+ 'append_url' => LiteSpeed_Cache_Purge::TYPE_PURGE_ERROR . '403',
23
  ),
24
  array(
25
+ 'title' => sprintf( __( 'Purge %s Error', 'litespeed-cache' ), '404' ),
26
+ 'desc' => sprintf( __( 'Purge error pages, including %s pages', 'litespeed-cache' ), '404' ),
 
27
  'icon' => 'purge-404',
28
+ 'append_url' => LiteSpeed_Cache_Purge::TYPE_PURGE_ERROR . '404',
29
  ),
30
  array(
31
+ 'title' => sprintf( __( 'Purge %s Error', 'litespeed-cache' ), '403' ),
32
+ 'desc' => sprintf( __( 'Purge error pages, including %s pages', 'litespeed-cache' ), '403' ),
33
  'title' => __( 'Purge 500 Error', 'litespeed-cache' ),
34
  'desc' => __( 'Purge error pages, including 500 pages', 'litespeed-cache' ),
 
35
  'icon' => 'purge-500',
36
+ 'append_url' => LiteSpeed_Cache_Purge::TYPE_PURGE_ERROR . '500',
37
  ),
38
  array(
39
+ 'title' => __( 'Purge All', 'litespeed-cache' ) . ' - LSCache',
40
+ 'desc' => __( 'Purge the litespeed cache entries created by this plugin', 'litespeed-cache' ),
 
41
  'icon' => 'purge-all',
42
+ 'append_url' => LiteSpeed_Cache_Purge::TYPE_PURGE_ALL_LSCACHE,
43
+ ),
44
+ array(
45
+ 'title' => __( 'Purge All', 'litespeed-cache' ) . ' - ' . __( 'CSS/JS Cache', 'litespeed-cache' ),
46
+ 'desc' => __( 'This will purge all minified/combined CSS/JS entries only', 'litespeed-cache' ),
47
+ 'icon' => 'purge-cssjs',
48
+ 'append_url' => LiteSpeed_Cache_Purge::TYPE_PURGE_ALL_CSSJS,
49
  ),
50
  ) ;
51
 
52
  if ( defined( 'LSCWP_OBJECT_CACHE' ) ) {
53
  $_panels[] = array(
54
+ 'title' => __( 'Purge All', 'litespeed-cache' ) . ' - ' . __( 'Object Cache', 'litespeed-cache' ),
55
  'desc' => __( 'Purge all the object caches', 'litespeed-cache' ),
 
56
  'icon' => 'purge-object',
57
+ 'append_url' => LiteSpeed_Cache_Purge::TYPE_PURGE_ALL_OBJECT,
58
  ) ;
59
  }
60
 
61
  if ( LiteSpeed_Cache_Router::opcache_enabled() ) {
62
  $_panels[] = array(
63
+ 'title' => __( 'Purge All', 'litespeed-cache' ) . ' - ' . __( 'Opcode Cache', 'litespeed-cache' ),
64
  'desc' => __( 'Reset the entire opcode cache', 'litespeed-cache' ),
 
65
  'icon' => 'purge-opcache',
66
+ 'append_url' => LiteSpeed_Cache_Purge::TYPE_PURGE_ALL_OPCACHE,
67
  ) ;
68
  }
69
 
70
+ $_panels[] = array(
71
+ 'title' => __( 'Purge All', 'litespeed-cache' ),
72
+ 'desc' => __( 'Purge the cache entries created by this plugin', 'litespeed-cache' ),
73
+ 'icon' => 'purge-all',
74
+ 'title_cls' => 'litespeed-warning',
75
+ 'newline' => true,
76
+ 'append_url' => LiteSpeed_Cache_Purge::TYPE_PURGE_ALL,
77
+ ) ;
78
+
79
  if ( ! is_multisite() || is_network_admin() ) {
80
  $_panels[] = array(
81
  'title' => __( 'Empty Entire Cache', 'litespeed-cache' ),
84
  'tag' => LiteSpeed_Cache::ACTION_PURGE_EMPTYCACHE,
85
  'icon' => 'empty-cache',
86
  'title_cls' => 'litespeed-danger',
 
87
  'cfm' => esc_html( __( 'This will clear EVERYTHING inside the cache.', 'litespeed-cache' ) ) . ' ' .
88
  esc_html( __( 'This may cause heavy load on the server.', 'litespeed-cache' ) ) . ' ' .
89
  esc_html( __( 'If only the WordPress site should be purged, use purge all.', 'litespeed-cache' ) )
99
  <div class="litespeed-panel-wrapper">
100
 
101
  <?php foreach ( $_panels as $v ): ?>
102
+ <?php $tag = ! empty( $v[ 'tag' ] ) ? $v[ 'tag' ] : LiteSpeed_Cache::ACTION_PURGE ; ?>
103
+ <?php $append_url = ! empty( $v[ 'append_url' ] ) ? $v[ 'append_url' ] : false ; ?>
104
 
105
  <?php if ( ! empty( $v[ 'newline' ] ) ) : ?>
106
  <div class='litespeed-col-br'></div>
107
  <?php endif; ?>
108
 
109
  <a class="litespeed-panel"
110
+ href="<?php echo LiteSpeed_Cache_Utility::build_url( $tag, $append_url ) ; ?>"
111
  <?php if ( ! empty( $v[ 'cfm' ] ) ) echo 'data-litespeed-cfm="' . $v[ 'cfm' ] . '"' ; ?>
112
  >
113
  <section class="litespeed-panel-wrapper-icon">
admin/tpl/setting/settings_debug.php CHANGED
@@ -9,6 +9,16 @@ if ( ! defined( 'WPINC' ) ) die ;
9
  </h3>
10
 
11
  <table><tbody>
 
 
 
 
 
 
 
 
 
 
12
  <tr>
13
  <th><?php echo __( 'Debug Log', 'litespeed-cache' ) ; ?></th>
14
  <td>
@@ -16,13 +26,13 @@ if ( ! defined( 'WPINC' ) ) die ;
16
  <?php echo $this->build_radio(
17
  LiteSpeed_Cache_Config::OPID_DEBUG,
18
  LiteSpeed_Cache_Config::VAL_OFF,
19
- __( 'Off', 'litespeed-cache' )
20
  ) ; ?>
21
 
22
  <?php echo $this->build_radio(
23
  LiteSpeed_Cache_Config::OPID_DEBUG,
24
  LiteSpeed_Cache_Config::VAL_ON,
25
- __( 'On', 'litespeed-cache' )
26
  ) ; ?>
27
 
28
  <?php echo $this->build_radio(
9
  </h3>
10
 
11
  <table><tbody>
12
+ <tr>
13
+ <th><?php echo __( 'Disable All Features', 'litespeed-cache' ) ; ?></th>
14
+ <td>
15
+ <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_DEBUG_DISABLE_ALL ) ; ?>
16
+ <div class="litespeed-desc">
17
+ <?php echo __( 'This will disable LSCache and all optimization features for debug purpose.', 'litespeed-cache' ) ; ?>
18
+ </div>
19
+ </td>
20
+ </tr>
21
+
22
  <tr>
23
  <th><?php echo __( 'Debug Log', 'litespeed-cache' ) ; ?></th>
24
  <td>
26
  <?php echo $this->build_radio(
27
  LiteSpeed_Cache_Config::OPID_DEBUG,
28
  LiteSpeed_Cache_Config::VAL_OFF,
29
+ __( 'OFF', 'litespeed-cache' )
30
  ) ; ?>
31
 
32
  <?php echo $this->build_radio(
33
  LiteSpeed_Cache_Config::OPID_DEBUG,
34
  LiteSpeed_Cache_Config::VAL_ON,
35
+ __( 'ON', 'litespeed-cache' )
36
  ) ; ?>
37
 
38
  <?php echo $this->build_radio(
admin/tpl/setting/settings_excludes.php CHANGED
@@ -3,13 +3,31 @@ if ( ! defined( 'WPINC' ) ) die ;
3
  ?>
4
 
5
  <h3 class="litespeed-title-short">
6
- <?php echo __('Do Not Cache Settings', 'litespeed-cache'); ?>
7
  <a href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:excludes" target="_blank" class="litespeed-learn-more"><?php echo __('Learn More', 'litespeed-cache') ; ?></a>
8
  </h3>
9
 
10
  <?php $this->cache_disabled_warning() ; ?>
11
 
12
  <table><tbody>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  <tr>
14
  <th><?php echo __( 'Do Not Cache URIs', 'litespeed-cache' ) ; ?></th>
15
  <td>
3
  ?>
4
 
5
  <h3 class="litespeed-title-short">
6
+ <?php echo __('Exclude Settings', 'litespeed-cache'); ?>
7
  <a href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:excludes" target="_blank" class="litespeed-learn-more"><?php echo __('Learn More', 'litespeed-cache') ; ?></a>
8
  </h3>
9
 
10
  <?php $this->cache_disabled_warning() ; ?>
11
 
12
  <table><tbody>
13
+ <tr>
14
+ <th><?php echo __( 'Force Cache URIs', 'litespeed-cache' ) ; ?></th>
15
+ <td>
16
+ <?php $this->build_textarea( LiteSpeed_Cache_Config::OPID_FORCE_CACHE_URI ) ; ?>
17
+ <div class="litespeed-desc">
18
+ <?php echo __('Paths containing these strings will be cached regardless of no-cacheable settings.', 'litespeed-cache'); ?>
19
+ <?php echo __('The URLs will be compared to the REQUEST_URI server variable.', 'litespeed-cache'); ?>
20
+ <?php echo sprintf( __( 'For example, for %s, %s can be used here.', 'litespeed-cache' ), '<code>/mypath/mypage?aa=bb</code>', '<code>mypage?aa=</code>' ) ; ?>
21
+ <br />
22
+ <i>
23
+ <?php echo sprintf( __( 'To match the beginning, add %s to the beginning of the item.', 'litespeed-cache' ), '<code>^</code>' ) ; ?>
24
+ <?php echo sprintf( __( 'To do an exact match, add %s to the end of the URL.', 'litespeed-cache' ), '<code>$</code>' ) ; ?>
25
+ <?php echo __('One per line.', 'litespeed-cache'); ?>
26
+ </i>
27
+ </div>
28
+ </td>
29
+ </tr>
30
+
31
  <tr>
32
  <th><?php echo __( 'Do Not Cache URIs', 'litespeed-cache' ) ; ?></th>
33
  <td>
cli/litespeed-cache-cli-admin.class.php CHANGED
@@ -33,6 +33,7 @@ class LiteSpeed_Cache_Cli_Admin
33
  LiteSpeed_Cache_Config::CRWL_TAGS,
34
  LiteSpeed_Cache_Config::CRWL_HTTP2,
35
  LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE,
 
36
  LiteSpeed_Cache_Config::OPID_DEBUG_LEVEL,
37
  LiteSpeed_Cache_Config::OPID_HEARTBEAT,
38
  LiteSpeed_Cache_Config::OPID_DEBUG_COOKIE,
@@ -147,6 +148,7 @@ class LiteSpeed_Cache_Cli_Admin
147
  case LiteSpeed_Cache_Config::CRWL_TAGS:
148
  case LiteSpeed_Cache_Config::CRWL_HTTP2:
149
  case LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE:
 
150
  case LiteSpeed_Cache_Config::OPID_DEBUG_LEVEL:
151
  case LiteSpeed_Cache_Config::OPID_HEARTBEAT:
152
  case LiteSpeed_Cache_Config::OPID_DEBUG_COOKIE:
33
  LiteSpeed_Cache_Config::CRWL_TAGS,
34
  LiteSpeed_Cache_Config::CRWL_HTTP2,
35
  LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE,
36
+ LiteSpeed_Cache_Config::OPID_DEBUG_DISABLE_ALL,
37
  LiteSpeed_Cache_Config::OPID_DEBUG_LEVEL,
38
  LiteSpeed_Cache_Config::OPID_HEARTBEAT,
39
  LiteSpeed_Cache_Config::OPID_DEBUG_COOKIE,
148
  case LiteSpeed_Cache_Config::CRWL_TAGS:
149
  case LiteSpeed_Cache_Config::CRWL_HTTP2:
150
  case LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE:
151
+ case LiteSpeed_Cache_Config::OPID_DEBUG_DISABLE_ALL:
152
  case LiteSpeed_Cache_Config::OPID_DEBUG_LEVEL:
153
  case LiteSpeed_Cache_Config::OPID_HEARTBEAT:
154
  case LiteSpeed_Cache_Config::OPID_DEBUG_COOKIE:
inc/api.class.php CHANGED
@@ -114,6 +114,28 @@ class LiteSpeed_Cache_API
114
  LiteSpeed_Cache_Control::set_nocache( $reason ?: 'api' ) ;
115
  }
116
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  /**
118
  * Get current not cacheable status
119
  *
114
  LiteSpeed_Cache_Control::set_nocache( $reason ?: 'api' ) ;
115
  }
116
 
117
+ /**
118
+ * Set cache status to cacheable ( By default cacheable status will be set when called WP hook `wp` )
119
+ *
120
+ * @since 2.2
121
+ * @access public
122
+ */
123
+ public static function set_cacheable( $reason )
124
+ {
125
+ LiteSpeed_Cache_Control::set_cacheable( $reason ) ;
126
+ }
127
+
128
+ /**
129
+ * Set cache status to force cacheable ( Will ignore most kinds of non-cacheable conditions )
130
+ *
131
+ * @since 2.2
132
+ * @access public
133
+ */
134
+ public static function set_force_cacheable( $reason )
135
+ {
136
+ LiteSpeed_Cache_Control::force_cacheable( $reason ) ;
137
+ }
138
+
139
  /**
140
  * Get current not cacheable status
141
  *
inc/config.class.php CHANGED
@@ -95,6 +95,7 @@ class LiteSpeed_Cache_Config
95
  // do NOT set default options for these three, it is used for admin.
96
  const ID_NOCACHE_COOKIES = 'nocache_cookies' ;
97
  const ID_NOCACHE_USERAGENTS = 'nocache_useragents' ;
 
98
  const OPID_DEBUG = 'debug' ;
99
  const OPID_ADMIN_IPS = 'admin_ips' ;
100
  const OPID_DEBUG_LEVEL = 'debug_level' ;
@@ -126,6 +127,7 @@ class LiteSpeed_Cache_Config
126
  const PURGE_DATE = 'D' ;
127
  const PURGE_TERM = 'T' ; // include category|tag|tax
128
  const PURGE_POST_TYPE = 'PT' ;
 
129
  const OPID_EXCLUDES_URI = 'excludes_uri' ;
130
  const OPID_EXCLUDES_QS = 'excludes_qs' ;
131
  const OPID_EXCLUDES_CAT = 'excludes_cat' ;
@@ -419,6 +421,10 @@ class LiteSpeed_Cache_Config
419
  }
420
 
421
  switch ( $type ) {
 
 
 
 
422
  case 'private' :
423
  $id = self::OPID_CACHE_URI_PRIV ;
424
  break ;
@@ -446,7 +452,7 @@ class LiteSpeed_Cache_Config
446
  $instance->update_options( array( $id => $list ) ) ;
447
 
448
  // Purge this page & redirect
449
- LiteSpeed_Cache_Purge::frontend_purge() ;
450
  exit() ;
451
  }
452
 
@@ -606,6 +612,7 @@ class LiteSpeed_Cache_Config
606
  self::OPID_LOGIN_COOKIE => '',
607
  self::OPID_CHECK_ADVANCEDCACHE => true,
608
  self::OPID_USE_HTTP_FOR_HTTPS_VARY => false,
 
609
  self::OPID_DEBUG => self::LOG_LEVEL_NONE,
610
  self::OPID_ADMIN_IPS => '127.0.0.1',
611
  self::OPID_DEBUG_LEVEL => false,
@@ -622,6 +629,7 @@ class LiteSpeed_Cache_Config
622
  self::OPID_404_TTL => 3600,
623
  self::OPID_500_TTL => 3600,
624
  self::OPID_PURGE_BY_POST => implode('.', $default_purge_options),
 
625
  self::OPID_EXCLUDES_URI => '',
626
  self::OPID_EXCLUDES_QS => '',
627
  self::OPID_EXCLUDES_CAT => '',
95
  // do NOT set default options for these three, it is used for admin.
96
  const ID_NOCACHE_COOKIES = 'nocache_cookies' ;
97
  const ID_NOCACHE_USERAGENTS = 'nocache_useragents' ;
98
+ const OPID_DEBUG_DISABLE_ALL = 'debug_disable_all' ;
99
  const OPID_DEBUG = 'debug' ;
100
  const OPID_ADMIN_IPS = 'admin_ips' ;
101
  const OPID_DEBUG_LEVEL = 'debug_level' ;
127
  const PURGE_DATE = 'D' ;
128
  const PURGE_TERM = 'T' ; // include category|tag|tax
129
  const PURGE_POST_TYPE = 'PT' ;
130
+ const OPID_FORCE_CACHE_URI = 'forced_cache_uri' ;
131
  const OPID_EXCLUDES_URI = 'excludes_uri' ;
132
  const OPID_EXCLUDES_QS = 'excludes_qs' ;
133
  const OPID_EXCLUDES_CAT = 'excludes_cat' ;
421
  }
422
 
423
  switch ( $type ) {
424
+ case 'forced_cache' :
425
+ $id = self::OPID_FORCE_CACHE_URI ;
426
+ break ;
427
+
428
  case 'private' :
429
  $id = self::OPID_CACHE_URI_PRIV ;
430
  break ;
452
  $instance->update_options( array( $id => $list ) ) ;
453
 
454
  // Purge this page & redirect
455
+ LiteSpeed_Cache_Purge::purge_front() ;
456
  exit() ;
457
  }
458
 
612
  self::OPID_LOGIN_COOKIE => '',
613
  self::OPID_CHECK_ADVANCEDCACHE => true,
614
  self::OPID_USE_HTTP_FOR_HTTPS_VARY => false,
615
+ self::OPID_DEBUG_DISABLE_ALL => false,
616
  self::OPID_DEBUG => self::LOG_LEVEL_NONE,
617
  self::OPID_ADMIN_IPS => '127.0.0.1',
618
  self::OPID_DEBUG_LEVEL => false,
629
  self::OPID_404_TTL => 3600,
630
  self::OPID_500_TTL => 3600,
631
  self::OPID_PURGE_BY_POST => implode('.', $default_purge_options),
632
+ self::OPID_FORCE_CACHE_URI => '',
633
  self::OPID_EXCLUDES_URI => '',
634
  self::OPID_EXCLUDES_QS => '',
635
  self::OPID_EXCLUDES_CAT => '',
inc/control.class.php CHANGED
@@ -16,6 +16,7 @@ class LiteSpeed_Cache_Control
16
  const BM_PRIVATE = 2 ;
17
  const BM_SHARED = 4 ;
18
  const BM_NO_VARY = 8 ;
 
19
  const BM_PUBLIC_FORCED = 64 ;
20
  const BM_STALE = 128 ;
21
  const BM_NOTCACHEABLE = 256 ;
@@ -78,7 +79,7 @@ class LiteSpeed_Cache_Control
78
  // NOTE: If any strange resource doesn't use normal WP logic `wp_loaded` hook, rewrite rule can handle it
79
  $cache_res = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_RES ) ;
80
  if ( $cache_res ) {
81
- $uri = esc_url( $_SERVER["REQUEST_URI"] ) ;
82
  $pattern = '!' . LSCWP_CONTENT_FOLDER . LiteSpeed_Cache_Admin_Rules::RW_PATTERN_RES . '!' ;
83
  if ( preg_match( $pattern, $uri ) ) {
84
  add_action( 'wp_loaded', 'LiteSpeed_Cache_Control::set_cacheable', 5 ) ;
@@ -238,10 +239,34 @@ class LiteSpeed_Cache_Control
238
  * @access public
239
  * @since 1.1.3
240
  */
241
- public static function set_cacheable()
242
  {
243
  self::$_control |= self::BM_CACHEABLE ;
244
- LiteSpeed_Cache_Log::debug( '[Ctrl] X Cache_control init on' ) ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245
  }
246
 
247
  /**
@@ -272,6 +297,17 @@ class LiteSpeed_Cache_Control
272
  return self::$_control & self::BM_NOTCACHEABLE ;
273
  }
274
 
 
 
 
 
 
 
 
 
 
 
 
275
  /**
276
  * Check current cacheable status
277
  *
@@ -281,12 +317,14 @@ class LiteSpeed_Cache_Control
281
  */
282
  public static function is_cacheable()
283
  {
 
 
 
 
 
284
  return ! self::isset_notcacheable() && self::$_control & self::BM_CACHEABLE ;
285
  }
286
 
287
-
288
-
289
-
290
  /**
291
  * Set a custom TTL to use with the request if needed.
292
  *
@@ -448,6 +486,16 @@ class LiteSpeed_Cache_Control
448
  */
449
  public static function finalize()
450
  {
 
 
 
 
 
 
 
 
 
 
451
  // if is not cacheable, terminate check
452
  // Even no need to run 3rd party hook
453
  if ( ! self::is_cacheable() ) {
@@ -507,7 +555,7 @@ class LiteSpeed_Cache_Control
507
  return ;
508
  }
509
 
510
- if ( isset($_SERVER['LSCACHE_VARY_VALUE']) && $_SERVER['LSCACHE_VARY_VALUE'] === 'ismobile' ) {
511
  if ( ! wp_is_mobile() && ! self::is_mobile() ) {
512
  self::set_nocache( 'is not mobile' ) ;
513
  return ;
@@ -562,66 +610,65 @@ class LiteSpeed_Cache_Control
562
  // Check private cache URI setting
563
  $excludes = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_URI_PRIV ) ;
564
  if ( ! empty( $excludes ) ) {
565
- $uri = esc_url( $_SERVER[ 'REQUEST_URI' ] ) ;
566
- $result = LiteSpeed_Cache_Utility::str_hit_array( $uri, explode( "\n", $excludes ) ) ;
567
  if ( $result ) {
568
  self::set_private( 'Admin cfg Private Cached URI: ' . $result ) ;
569
  }
570
  }
571
 
572
- // Check if URI is excluded from cache
573
- $excludes = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_EXCLUDES_URI ) ;
574
- if ( ! empty( $excludes ) ) {
575
- $uri = esc_url( $_SERVER[ 'REQUEST_URI' ] ) ;
576
- $result = LiteSpeed_Cache_Utility::str_hit_array( $uri, explode( "\n", $excludes ) ) ;
577
- if ( $result ) {
578
- return $this->_no_cache_for( 'Admin configured URI Do not cache: ' . $result ) ;
 
 
579
  }
580
- }
581
 
582
- // Check QS excluded setting
583
- $excludes = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_EXCLUDES_QS ) ;
584
- if ( ! empty( $excludes ) && $qs = $this->_is_qs_excluded( explode( "\n", $excludes ) ) ) {
585
- return $this->_no_cache_for( 'Admin configured QS Do not cache: ' . $qs ) ;
586
- }
587
 
588
- $excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::OPID_EXCLUDES_CAT) ;
589
- if ( ! empty($excludes) && has_category(explode(',', $excludes)) ) {
590
- return $this->_no_cache_for('Admin configured Category Do not cache.') ;
591
- }
592
 
593
- $excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::OPID_EXCLUDES_TAG) ;
594
- if ( ! empty($excludes) && has_tag(explode(',', $excludes)) ) {
595
- return $this->_no_cache_for('Admin configured Tag Do not cache.') ;
596
- }
597
 
598
- $excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::ID_NOCACHE_COOKIES) ;
599
- if ( ! empty($excludes) && ! empty($_COOKIE) ) {
600
- $exclude_list = explode('|', $excludes) ;
601
 
602
- foreach( $_COOKIE as $key=>$val) {
603
- if ( in_array($key, $exclude_list) ) {
604
- return $this->_no_cache_for('Admin configured Cookie Do not cache.') ;
 
605
  }
606
  }
607
- }
608
 
609
- $excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::ID_NOCACHE_USERAGENTS) ;
610
- if ( ! empty($excludes) && isset($_SERVER['HTTP_USER_AGENT']) ) {
611
- $pattern = '/' . $excludes . '/' ;
612
- $nummatches = preg_match($pattern, $_SERVER['HTTP_USER_AGENT']) ;
613
- if ( $nummatches ) {
614
- return $this->_no_cache_for('Admin configured User Agent Do not cache.') ;
 
615
  }
616
- }
617
 
618
- // Check if is exclude roles ( Need to set Vary too )
619
- if ( $result = LiteSpeed_Cache_Config::get_instance()->in_exclude_cache_roles() ) {
620
- return $this->_no_cache_for( 'Role Excludes setting ' . $result ) ;
 
621
  }
622
 
623
-
624
-
625
  return true ;
626
  }
627
 
16
  const BM_PRIVATE = 2 ;
17
  const BM_SHARED = 4 ;
18
  const BM_NO_VARY = 8 ;
19
+ const BM_FORCED_CACHEABLE = 32 ;
20
  const BM_PUBLIC_FORCED = 64 ;
21
  const BM_STALE = 128 ;
22
  const BM_NOTCACHEABLE = 256 ;
79
  // NOTE: If any strange resource doesn't use normal WP logic `wp_loaded` hook, rewrite rule can handle it
80
  $cache_res = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_RES ) ;
81
  if ( $cache_res ) {
82
+ $uri = esc_url( $_SERVER["REQUEST_URI"] ) ;// todo: check if need esc_url()
83
  $pattern = '!' . LSCWP_CONTENT_FOLDER . LiteSpeed_Cache_Admin_Rules::RW_PATTERN_RES . '!' ;
84
  if ( preg_match( $pattern, $uri ) ) {
85
  add_action( 'wp_loaded', 'LiteSpeed_Cache_Control::set_cacheable', 5 ) ;
239
  * @access public
240
  * @since 1.1.3
241
  */
242
+ public static function set_cacheable( $reason = false )
243
  {
244
  self::$_control |= self::BM_CACHEABLE ;
245
+
246
+ if ( ! is_string( $reason ) ) {
247
+ $reason = false ;
248
+ }
249
+
250
+ if ( $reason ) {
251
+ $reason = ' [reason] ' . $reason ;
252
+ }
253
+ LiteSpeed_Cache_Log::debug( '[Ctrl] X Cache_control init on' . $reason ) ;
254
+ }
255
+
256
+ /**
257
+ * This will disable non-cacheable BM
258
+ *
259
+ * @access public
260
+ * @since 2.2
261
+ */
262
+ public static function force_cacheable( $reason = false )
263
+ {
264
+ self::$_control |= self::BM_FORCED_CACHEABLE ;
265
+
266
+ if ( $reason ) {
267
+ $reason = ' [reason] ' . $reason ;
268
+ }
269
+ LiteSpeed_Cache_Log::debug( '[Ctrl] Forced cacheable' . $reason ) ;
270
  }
271
 
272
  /**
297
  return self::$_control & self::BM_NOTCACHEABLE ;
298
  }
299
 
300
+ /**
301
+ * Check current force cacheable bit set
302
+ *
303
+ * @access public
304
+ * @since 2.2
305
+ */
306
+ public static function is_forced_cacheable()
307
+ {
308
+ return self::$_control & self::BM_FORCED_CACHEABLE ;
309
+ }
310
+
311
  /**
312
  * Check current cacheable status
313
  *
317
  */
318
  public static function is_cacheable()
319
  {
320
+ // If its forced cacheable
321
+ if ( self::is_forced_cacheable() ) {
322
+ return true ;
323
+ }
324
+
325
  return ! self::isset_notcacheable() && self::$_control & self::BM_CACHEABLE ;
326
  }
327
 
 
 
 
328
  /**
329
  * Set a custom TTL to use with the request if needed.
330
  *
486
  */
487
  public static function finalize()
488
  {
489
+ // Check if URI is forced cache
490
+ $excludes = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_FORCE_CACHE_URI ) ;
491
+ if ( ! empty( $excludes ) ) {
492
+ $result = LiteSpeed_Cache_Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], explode( "\n", $excludes ) ) ;
493
+ if ( $result ) {
494
+ self::force_cacheable() ;
495
+ LiteSpeed_Cache_Log::debug( '[Ctrl] Forced cacheable due to setting: ' . $result ) ;
496
+ }
497
+ }
498
+
499
  // if is not cacheable, terminate check
500
  // Even no need to run 3rd party hook
501
  if ( ! self::is_cacheable() ) {
555
  return ;
556
  }
557
 
558
+ if ( isset($_SERVER['LSCACHE_VARY_VALUE']) && strpos( $_SERVER['LSCACHE_VARY_VALUE'], 'ismobile' ) !== false ) {
559
  if ( ! wp_is_mobile() && ! self::is_mobile() ) {
560
  self::set_nocache( 'is not mobile' ) ;
561
  return ;
610
  // Check private cache URI setting
611
  $excludes = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_URI_PRIV ) ;
612
  if ( ! empty( $excludes ) ) {
613
+ $result = LiteSpeed_Cache_Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], explode( "\n", $excludes ) ) ;
 
614
  if ( $result ) {
615
  self::set_private( 'Admin cfg Private Cached URI: ' . $result ) ;
616
  }
617
  }
618
 
619
+ if ( ! self::is_forced_cacheable() ) {
620
+
621
+ // Check if URI is excluded from cache
622
+ $excludes = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_EXCLUDES_URI ) ;
623
+ if ( ! empty( $excludes ) ) {
624
+ $result = LiteSpeed_Cache_Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], explode( "\n", $excludes ) ) ;
625
+ if ( $result ) {
626
+ return $this->_no_cache_for( 'Admin configured URI Do not cache: ' . $result ) ;
627
+ }
628
  }
 
629
 
630
+ // Check QS excluded setting
631
+ $excludes = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_EXCLUDES_QS ) ;
632
+ if ( ! empty( $excludes ) && $qs = $this->_is_qs_excluded( explode( "\n", $excludes ) ) ) {
633
+ return $this->_no_cache_for( 'Admin configured QS Do not cache: ' . $qs ) ;
634
+ }
635
 
636
+ $excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::OPID_EXCLUDES_CAT) ;
637
+ if ( ! empty($excludes) && has_category(explode(',', $excludes)) ) {
638
+ return $this->_no_cache_for('Admin configured Category Do not cache.') ;
639
+ }
640
 
641
+ $excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::OPID_EXCLUDES_TAG) ;
642
+ if ( ! empty($excludes) && has_tag(explode(',', $excludes)) ) {
643
+ return $this->_no_cache_for('Admin configured Tag Do not cache.') ;
644
+ }
645
 
646
+ $excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::ID_NOCACHE_COOKIES) ;
647
+ if ( ! empty($excludes) && ! empty($_COOKIE) ) {
648
+ $exclude_list = explode('|', $excludes) ;
649
 
650
+ foreach( $_COOKIE as $key=>$val) {
651
+ if ( in_array($key, $exclude_list) ) {
652
+ return $this->_no_cache_for('Admin configured Cookie Do not cache.') ;
653
+ }
654
  }
655
  }
 
656
 
657
+ $excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::ID_NOCACHE_USERAGENTS) ;
658
+ if ( ! empty($excludes) && isset($_SERVER['HTTP_USER_AGENT']) ) {
659
+ $pattern = '/' . $excludes . '/' ;
660
+ $nummatches = preg_match($pattern, $_SERVER['HTTP_USER_AGENT']) ;
661
+ if ( $nummatches ) {
662
+ return $this->_no_cache_for('Admin configured User Agent Do not cache.') ;
663
+ }
664
  }
 
665
 
666
+ // Check if is exclude roles ( Need to set Vary too )
667
+ if ( $result = LiteSpeed_Cache_Config::get_instance()->in_exclude_cache_roles() ) {
668
+ return $this->_no_cache_for( 'Role Excludes setting ' . $result ) ;
669
+ }
670
  }
671
 
 
 
672
  return true ;
673
  }
674
 
inc/gui.class.php CHANGED
@@ -275,7 +275,7 @@ class LiteSpeed_Cache_GUI
275
  'parent' => 'litespeed-menu',
276
  'id' => 'litespeed-purge-single',
277
  'title' => __( 'Purge this page', 'litespeed-cache' ),
278
- 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_FRONT_PURGE, false, false, true ),
279
  'meta' => array( 'tabindex' => '0' ),
280
  ) );
281
 
@@ -286,6 +286,13 @@ class LiteSpeed_Cache_GUI
286
  'meta' => array( 'tabindex' => '0' ),
287
  ) );
288
 
 
 
 
 
 
 
 
289
  $wp_admin_bar->add_menu( array(
290
  'parent' => 'litespeed-single-action',
291
  'id' => 'litespeed-single-noncache',
@@ -331,7 +338,7 @@ class LiteSpeed_Cache_GUI
331
  $wp_admin_bar->add_menu( array(
332
  'id' => 'litespeed-menu',
333
  'title' => '<span class="ab-icon" title="' . __( 'LiteSpeed Cache Purge All', 'litespeed-cache' ) . '""></span>',
334
- 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_PURGE_ALL ),
335
  'meta' => array( 'tabindex' => 0, 'class' => 'litespeed-top-toolbar' ),
336
  ) ) ;
337
  }
@@ -372,16 +379,24 @@ class LiteSpeed_Cache_GUI
372
  $wp_admin_bar->add_menu( array(
373
  'parent' => 'litespeed-menu',
374
  'id' => 'litespeed-purge-all',
375
- 'title' => __( 'LSCache Purge All', 'litespeed-cache' ),
376
- 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_PURGE_ALL ),
 
 
 
 
 
 
 
 
377
  'meta' => array( 'tabindex' => '0' ),
378
  ) );
379
 
380
  $wp_admin_bar->add_menu( array(
381
  'parent' => 'litespeed-menu',
382
  'id' => 'litespeed-purge-cssjs',
383
- 'title' => __( 'Purge CSS/JS Cache', 'litespeed-cache' ),
384
- 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_PURGE_CSSJS ),
385
  'meta' => array( 'tabindex' => '0' ),
386
  ) );
387
 
@@ -389,7 +404,7 @@ class LiteSpeed_Cache_GUI
389
  $wp_admin_bar->add_menu( array(
390
  'parent' => 'litespeed-menu',
391
  'id' => 'litespeed-purge-cloudflare',
392
- 'title' => __( 'Cloudflare Purge All', 'litespeed-cache' ),
393
  'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_CDN_CLOUDFLARE, LiteSpeed_Cache_CDN_Cloudflare::TYPE_PURGE_ALL ),
394
  'meta' => array( 'tabindex' => '0' ),
395
  ) );
@@ -399,8 +414,8 @@ class LiteSpeed_Cache_GUI
399
  $wp_admin_bar->add_menu( array(
400
  'parent' => 'litespeed-menu',
401
  'id' => 'litespeed-purge-object',
402
- 'title' => __( 'Object Cache Purge All', 'litespeed-cache' ),
403
- 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_PURGE, LiteSpeed_Cache_Purge::TYPE_OBJECT_PURGE_ALL ),
404
  'meta' => array( 'tabindex' => '0' ),
405
  ) );
406
  }
@@ -409,8 +424,8 @@ class LiteSpeed_Cache_GUI
409
  $wp_admin_bar->add_menu( array(
410
  'parent' => 'litespeed-menu',
411
  'id' => 'litespeed-purge-opcache',
412
- 'title' => __( 'Opcode Cache Purge All', 'litespeed-cache' ),
413
- 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_PURGE, LiteSpeed_Cache_Purge::TYPE_OPCACHE_PURGE_ALL ),
414
  'meta' => array( 'tabindex' => '0' ),
415
  ) );
416
  }
275
  'parent' => 'litespeed-menu',
276
  'id' => 'litespeed-purge-single',
277
  'title' => __( 'Purge this page', 'litespeed-cache' ),
278
+ 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_PURGE, LiteSpeed_Cache_Purge::TYPE_PURGE_FRONT, false, true ),
279
  'meta' => array( 'tabindex' => '0' ),
280
  ) );
281
 
286
  'meta' => array( 'tabindex' => '0' ),
287
  ) );
288
 
289
+ $wp_admin_bar->add_menu( array(
290
+ 'parent' => 'litespeed-single-action',
291
+ 'id' => 'litespeed-single-forced_cache',
292
+ 'title' => __( 'Forced cacheable', 'litespeed-cache' ),
293
+ 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_FRONT_EXCLUDE, 'forced_cache', false, true ),
294
+ ) );
295
+
296
  $wp_admin_bar->add_menu( array(
297
  'parent' => 'litespeed-single-action',
298
  'id' => 'litespeed-single-noncache',
338
  $wp_admin_bar->add_menu( array(
339
  'id' => 'litespeed-menu',
340
  'title' => '<span class="ab-icon" title="' . __( 'LiteSpeed Cache Purge All', 'litespeed-cache' ) . '""></span>',
341
+ 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_PURGE, LiteSpeed_Cache_Purge::TYPE_PURGE_ALL ),
342
  'meta' => array( 'tabindex' => 0, 'class' => 'litespeed-top-toolbar' ),
343
  ) ) ;
344
  }
379
  $wp_admin_bar->add_menu( array(
380
  'parent' => 'litespeed-menu',
381
  'id' => 'litespeed-purge-all',
382
+ 'title' => __( 'Purge All', 'litespeed-cache' ),
383
+ 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_PURGE, LiteSpeed_Cache_Purge::TYPE_PURGE_ALL ),
384
+ 'meta' => array( 'tabindex' => '0' ),
385
+ ) );
386
+
387
+ $wp_admin_bar->add_menu( array(
388
+ 'parent' => 'litespeed-menu',
389
+ 'id' => 'litespeed-lscache-purge-all',
390
+ 'title' => __( 'Purge All', 'litespeed-cache' ) . ' - ' . __( 'LSCache', 'litespeed-cache' ),
391
+ 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_PURGE, LiteSpeed_Cache_Purge::TYPE_PURGE_ALL_LSCACHE ),
392
  'meta' => array( 'tabindex' => '0' ),
393
  ) );
394
 
395
  $wp_admin_bar->add_menu( array(
396
  'parent' => 'litespeed-menu',
397
  'id' => 'litespeed-purge-cssjs',
398
+ 'title' => __( 'Purge All', 'litespeed-cache' ) . ' - ' . __( 'CSS/JS Cache', 'litespeed-cache' ),
399
+ 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_PURGE, LiteSpeed_Cache_Purge::TYPE_PURGE_ALL_CSSJS ),
400
  'meta' => array( 'tabindex' => '0' ),
401
  ) );
402
 
404
  $wp_admin_bar->add_menu( array(
405
  'parent' => 'litespeed-menu',
406
  'id' => 'litespeed-purge-cloudflare',
407
+ 'title' => __( 'Purge All', 'litespeed-cache' ) . ' - ' . __( 'Cloudflare', 'litespeed-cache' ),
408
  'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_CDN_CLOUDFLARE, LiteSpeed_Cache_CDN_Cloudflare::TYPE_PURGE_ALL ),
409
  'meta' => array( 'tabindex' => '0' ),
410
  ) );
414
  $wp_admin_bar->add_menu( array(
415
  'parent' => 'litespeed-menu',
416
  'id' => 'litespeed-purge-object',
417
+ 'title' => __( 'Purge All', 'litespeed-cache' ) . ' - ' . __( 'Object Cache', 'litespeed-cache' ),
418
+ 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_PURGE, LiteSpeed_Cache_Purge::TYPE_PURGE_ALL_OBJECT ),
419
  'meta' => array( 'tabindex' => '0' ),
420
  ) );
421
  }
424
  $wp_admin_bar->add_menu( array(
425
  'parent' => 'litespeed-menu',
426
  'id' => 'litespeed-purge-opcache',
427
+ 'title' => __( 'Purge All', 'litespeed-cache' ) . ' - ' . __( 'Opcode Cache', 'litespeed-cache' ),
428
+ 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_PURGE, LiteSpeed_Cache_Purge::TYPE_PURGE_ALL_OPCACHE ),
429
  'meta' => array( 'tabindex' => '0' ),
430
  ) );
431
  }
inc/litespeed-cache.class.php CHANGED
@@ -19,7 +19,7 @@ class LiteSpeed_Cache
19
  private static $_instance ;
20
 
21
  const PLUGIN_NAME = 'litespeed-cache' ;
22
- const PLUGIN_VERSION = '2.1.2' ;
23
 
24
  const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
25
 
@@ -29,12 +29,7 @@ class LiteSpeed_Cache
29
  const ACTION_SAVE_HTACCESS = 'save-htaccess' ;
30
  const ACTION_SAVE_SETTINGS = 'save-settings' ;
31
  const ACTION_SAVE_SETTINGS_NETWORK = 'save-settings-network' ;
32
- const ACTION_PURGE_ERRORS = 'PURGE_ERRORS' ;
33
- const ACTION_PURGE_PAGES = 'PURGE_PAGES' ;
34
- const ACTION_PURGE_CSSJS = 'PURGE_CSSJS' ;
35
  const ACTION_PURGE_BY = 'PURGE_BY' ;
36
- const ACTION_PURGE_FRONT = 'PURGE_FRONT' ;
37
- const ACTION_PURGE_ALL = 'PURGE_ALL' ;
38
  const ACTION_PURGE_EMPTYCACHE = 'PURGE_EMPTYCACHE' ;
39
  const ACTION_QS_PURGE = 'PURGE' ;
40
  const ACTION_QS_PURGE_SINGLE = 'PURGESINGLE' ;
@@ -50,7 +45,6 @@ class LiteSpeed_Cache
50
  const ACTION_CDN_CLOUDFLARE = 'cdn_cloudflare' ;
51
  const ACTION_CDN_QUICCLOUD = 'cdn_quiccloud' ;
52
 
53
- const ACTION_FRONT_PURGE = 'front-purge' ;
54
  const ACTION_FRONT_EXCLUDE = 'front-exclude' ;
55
 
56
  const ACTION_DB_OPTIMIZE = 'db_optimize' ;
@@ -99,6 +93,10 @@ class LiteSpeed_Cache
99
  include_once LSCWP_DIR . 'thirdparty/lscwp-registry-3rd.php' ;
100
  }
101
 
 
 
 
 
102
  /**
103
  * This needs to be before activation because admin-rules.class.php need const `LSCWP_CONTENT_FOLDER`
104
  * @since 1.9.1 Moved up
@@ -120,7 +118,7 @@ class LiteSpeed_Cache
120
  // Check if there is a purge request in queue
121
  if ( $purge_queue = get_option( LiteSpeed_Cache_Purge::PURGE_QUEUE ) ) {
122
  @header( $purge_queue ) ;
123
- LiteSpeed_Cache_Log::debug( '[Boot] Purge Queue found&sent: ' . $purge_queue ) ;
124
  delete_option( LiteSpeed_Cache_Purge::PURGE_QUEUE ) ;
125
  }
126
 
@@ -171,6 +169,11 @@ class LiteSpeed_Cache
171
  // return ;
172
  // }
173
 
 
 
 
 
 
174
  ob_start( array( $this, 'send_headers_force' ) ) ;
175
  add_action( 'shutdown', array( $this, 'send_headers' ), 0 ) ;
176
  add_action( 'wp_footer', 'LiteSpeed_Cache::footer_hook' ) ;
@@ -264,30 +267,8 @@ class LiteSpeed_Cache
264
  $msg = __( 'Crawler blacklist is saved.', 'litespeed-cache' ) ;
265
  break ;
266
 
267
- case LiteSpeed_Cache::ACTION_PURGE_FRONT:
268
- LiteSpeed_Cache_Purge::purge_front() ;
269
- $msg = __( 'Notified LiteSpeed Web Server to purge the front page.', 'litespeed-cache' ) ;
270
- break ;
271
-
272
- case LiteSpeed_Cache::ACTION_PURGE_PAGES:
273
- LiteSpeed_Cache_Purge::purge_pages() ;
274
- $msg = __( 'Notified LiteSpeed Web Server to purge pages.', 'litespeed-cache' ) ;
275
- break ;
276
-
277
- case LiteSpeed_Cache::ACTION_PURGE_CSSJS:
278
- LiteSpeed_Cache_Purge::purge_cssjs() ;
279
- $msg = __( 'Notified LiteSpeed Web Server to purge CSS/JS entries.', 'litespeed-cache' ) ;
280
- break ;
281
-
282
- case LiteSpeed_Cache::ACTION_PURGE_ERRORS:
283
- LiteSpeed_Cache_Purge::purge_errors() ;
284
- $msg = __( 'Notified LiteSpeed Web Server to purge error pages.', 'litespeed-cache' ) ;
285
- break ;
286
-
287
- case LiteSpeed_Cache::ACTION_PURGE_ALL:
288
  case LiteSpeed_Cache::ACTION_QS_PURGE_ALL:
289
  LiteSpeed_Cache_Purge::purge_all() ;
290
- $msg = __( 'Notified LiteSpeed Web Server to purge all caches.', 'litespeed-cache' ) ;
291
  break;
292
 
293
  case LiteSpeed_Cache::ACTION_PURGE_EMPTYCACHE:
@@ -297,11 +278,6 @@ class LiteSpeed_Cache
297
  $msg = __( 'Notified LiteSpeed Web Server to purge everything.', 'litespeed-cache' ) ;
298
  break;
299
 
300
- case LiteSpeed_Cache::ACTION_FRONT_PURGE:
301
- // redirect inside
302
- LiteSpeed_Cache_Purge::frontend_purge() ;
303
- break ;
304
-
305
  case LiteSpeed_Cache::ACTION_FRONT_EXCLUDE:
306
  // redirect inside
307
  LiteSpeed_Cache_Config::frontend_save() ;
@@ -440,7 +416,7 @@ class LiteSpeed_Cache
440
  */
441
  public static function footer_hook()
442
  {
443
- LiteSpeed_Cache_Log::debug( '[Boot] Footer hook called' ) ;
444
  if ( ! defined( 'LITESPEED_FOOTER_CALLED' ) ) {
445
  define( 'LITESPEED_FOOTER_CALLED', true ) ;
446
  }
@@ -455,22 +431,22 @@ class LiteSpeed_Cache
455
  private function _check_is_html( $buffer = null )
456
  {
457
  if ( ! defined( 'LITESPEED_FOOTER_CALLED' ) ) {
458
- LiteSpeed_Cache_Log::debug2( '[Boot] CHK html bypass: miss footer const' ) ;
459
  return ;
460
  }
461
 
462
  if ( defined( 'DOING_AJAX' ) ) {
463
- LiteSpeed_Cache_Log::debug2( '[Boot] CHK html bypass: doing ajax' ) ;
464
  return ;
465
  }
466
 
467
  if ( defined( 'DOING_CRON' ) ) {
468
- LiteSpeed_Cache_Log::debug2( '[Boot] CHK html bypass: doing cron' ) ;
469
  return ;
470
  }
471
 
472
  if ( $_SERVER[ 'REQUEST_METHOD' ] !== 'GET' ) {
473
- LiteSpeed_Cache_Log::debug2( '[Boot] CHK html bypass: not get method ' . $_SERVER[ 'REQUEST_METHOD' ] ) ;
474
  return ;
475
  }
476
 
@@ -489,11 +465,11 @@ class LiteSpeed_Cache
489
  $is_html = stripos( $buffer, '<html' ) === 0 || stripos( $buffer, '<!DOCTYPE' ) === 0 ;
490
 
491
  if ( ! $is_html ) {
492
- LiteSpeed_Cache_Log::debug( '[Boot] Footer check failed: ' . ob_get_level() . '-' . substr( $buffer, 0, 100 ) ) ;
493
  return ;
494
  }
495
 
496
- LiteSpeed_Cache_Log::debug( '[Boot] Footer check passed' ) ;
497
 
498
  if ( ! defined( 'LITESPEED_IS_HTML' ) ) {
499
  define( 'LITESPEED_IS_HTML', true ) ;
@@ -581,7 +557,7 @@ class LiteSpeed_Cache
581
  $running_info_showing = ( defined( 'LITESPEED_IS_HTML' ) && LITESPEED_IS_HTML ) || ( defined( 'LSCACHE_IS_ESI' ) && LSCACHE_IS_ESI ) ;
582
  if ( defined( 'LSCACHE_ESI_SILENCE' ) ) {
583
  $running_info_showing = false ;
584
- LiteSpeed_Cache_Log::debug( '[Boot] ESI silence' ) ;
585
  }
586
 
587
  if ( $running_info_showing ) {
19
  private static $_instance ;
20
 
21
  const PLUGIN_NAME = 'litespeed-cache' ;
22
+ const PLUGIN_VERSION = '2.2' ;
23
 
24
  const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
25
 
29
  const ACTION_SAVE_HTACCESS = 'save-htaccess' ;
30
  const ACTION_SAVE_SETTINGS = 'save-settings' ;
31
  const ACTION_SAVE_SETTINGS_NETWORK = 'save-settings-network' ;
 
 
 
32
  const ACTION_PURGE_BY = 'PURGE_BY' ;
 
 
33
  const ACTION_PURGE_EMPTYCACHE = 'PURGE_EMPTYCACHE' ;
34
  const ACTION_QS_PURGE = 'PURGE' ;
35
  const ACTION_QS_PURGE_SINGLE = 'PURGESINGLE' ;
45
  const ACTION_CDN_CLOUDFLARE = 'cdn_cloudflare' ;
46
  const ACTION_CDN_QUICCLOUD = 'cdn_quiccloud' ;
47
 
 
48
  const ACTION_FRONT_EXCLUDE = 'front-exclude' ;
49
 
50
  const ACTION_DB_OPTIMIZE = 'db_optimize' ;
93
  include_once LSCWP_DIR . 'thirdparty/lscwp-registry-3rd.php' ;
94
  }
95
 
96
+ if ( self::config( LiteSpeed_Cache_Config::OPID_DEBUG_DISABLE_ALL ) ) {
97
+ define( 'LITESPEED_DISABLE_ALL', true ) ;
98
+ }
99
+
100
  /**
101
  * This needs to be before activation because admin-rules.class.php need const `LSCWP_CONTENT_FOLDER`
102
  * @since 1.9.1 Moved up
118
  // Check if there is a purge request in queue
119
  if ( $purge_queue = get_option( LiteSpeed_Cache_Purge::PURGE_QUEUE ) ) {
120
  @header( $purge_queue ) ;
121
+ LiteSpeed_Cache_Log::debug( '[Core] Purge Queue found&sent: ' . $purge_queue ) ;
122
  delete_option( LiteSpeed_Cache_Purge::PURGE_QUEUE ) ;
123
  }
124
 
169
  // return ;
170
  // }
171
 
172
+ if ( defined( 'LITESPEED_DISABLE_ALL' ) ) {
173
+ LiteSpeed_Cache_Log::debug( '[Core] Bypassed due to debug disable all setting' ) ;
174
+ return ;
175
+ }
176
+
177
  ob_start( array( $this, 'send_headers_force' ) ) ;
178
  add_action( 'shutdown', array( $this, 'send_headers' ), 0 ) ;
179
  add_action( 'wp_footer', 'LiteSpeed_Cache::footer_hook' ) ;
267
  $msg = __( 'Crawler blacklist is saved.', 'litespeed-cache' ) ;
268
  break ;
269
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270
  case LiteSpeed_Cache::ACTION_QS_PURGE_ALL:
271
  LiteSpeed_Cache_Purge::purge_all() ;
 
272
  break;
273
 
274
  case LiteSpeed_Cache::ACTION_PURGE_EMPTYCACHE:
278
  $msg = __( 'Notified LiteSpeed Web Server to purge everything.', 'litespeed-cache' ) ;
279
  break;
280
 
 
 
 
 
 
281
  case LiteSpeed_Cache::ACTION_FRONT_EXCLUDE:
282
  // redirect inside
283
  LiteSpeed_Cache_Config::frontend_save() ;
416
  */
417
  public static function footer_hook()
418
  {
419
+ LiteSpeed_Cache_Log::debug( '[Core] Footer hook called' ) ;
420
  if ( ! defined( 'LITESPEED_FOOTER_CALLED' ) ) {
421
  define( 'LITESPEED_FOOTER_CALLED', true ) ;
422
  }
431
  private function _check_is_html( $buffer = null )
432
  {
433
  if ( ! defined( 'LITESPEED_FOOTER_CALLED' ) ) {
434
+ LiteSpeed_Cache_Log::debug2( '[Core] CHK html bypass: miss footer const' ) ;
435
  return ;
436
  }
437
 
438
  if ( defined( 'DOING_AJAX' ) ) {
439
+ LiteSpeed_Cache_Log::debug2( '[Core] CHK html bypass: doing ajax' ) ;
440
  return ;
441
  }
442
 
443
  if ( defined( 'DOING_CRON' ) ) {
444
+ LiteSpeed_Cache_Log::debug2( '[Core] CHK html bypass: doing cron' ) ;
445
  return ;
446
  }
447
 
448
  if ( $_SERVER[ 'REQUEST_METHOD' ] !== 'GET' ) {
449
+ LiteSpeed_Cache_Log::debug2( '[Core] CHK html bypass: not get method ' . $_SERVER[ 'REQUEST_METHOD' ] ) ;
450
  return ;
451
  }
452
 
465
  $is_html = stripos( $buffer, '<html' ) === 0 || stripos( $buffer, '<!DOCTYPE' ) === 0 ;
466
 
467
  if ( ! $is_html ) {
468
+ LiteSpeed_Cache_Log::debug( '[Core] Footer check failed: ' . ob_get_level() . '-' . substr( $buffer, 0, 100 ) ) ;
469
  return ;
470
  }
471
 
472
+ LiteSpeed_Cache_Log::debug( '[Core] Footer check passed' ) ;
473
 
474
  if ( ! defined( 'LITESPEED_IS_HTML' ) ) {
475
  define( 'LITESPEED_IS_HTML', true ) ;
557
  $running_info_showing = ( defined( 'LITESPEED_IS_HTML' ) && LITESPEED_IS_HTML ) || ( defined( 'LSCACHE_IS_ESI' ) && LSCACHE_IS_ESI ) ;
558
  if ( defined( 'LSCACHE_ESI_SILENCE' ) ) {
559
  $running_info_showing = false ;
560
+ LiteSpeed_Cache_Log::debug( '[Core] ESI silence' ) ;
561
  }
562
 
563
  if ( $running_info_showing ) {
inc/object.class.php CHANGED
@@ -51,7 +51,7 @@ class LiteSpeed_Cache_Object
51
  */
52
  private function __construct( $cfg = false )
53
  {
54
- defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug2( 'Object: init' ) ;
55
 
56
  $this->_oc_data_file = WP_CONTENT_DIR . '/.object-cache.ini' ;
57
 
@@ -74,7 +74,7 @@ class LiteSpeed_Cache_Object
74
  }
75
  $this->_cfg_enabled = $cfg[ LiteSpeed_Cache_Config::OPID_CACHE_OBJECT ] && class_exists( $this->_oc_driver ) && $this->_cfg_host ;
76
 
77
- defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( 'Object: init with cfg result : ', $this->_cfg_enabled ) ;
78
  }
79
  elseif ( class_exists( 'LiteSpeed_Cache' ) ) {
80
  $this->_cfg_method = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_KIND ) ? true : false ;
@@ -174,14 +174,14 @@ class LiteSpeed_Cache_Object
174
 
175
  // Update cls file
176
  if ( ! file_exists( $wp_file ) || md5_file( $wp_file ) !== md5_file( $ori_file ) ) {
177
- defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( 'Object: copying object-cache.php file to ' . $wp_file ) ;
178
  copy( $ori_file, $wp_file ) ;
179
  }
180
  }
181
  else {
182
  // To delete file
183
  if ( file_exists( $wp_file ) ) {
184
- defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( 'Object: removing ' . $wp_file ) ;
185
  unlink( $wp_file ) ;
186
  }
187
  file_exists( $this->_oc_data_file ) && unlink( $this->_oc_data_file ) ;
@@ -223,11 +223,11 @@ class LiteSpeed_Cache_Object
223
  */
224
  public function reconnect( $cfg )
225
  {
226
- defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( 'Object: Reconnecting' ) ;
227
  // error_log( 'Object: reconnect !' ) ;
228
  if ( isset( $this->_conn ) ) {
229
  // error_log( 'Object: Quiting existing connection!' ) ;
230
- defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( 'Object: Quiting existing connection' ) ;
231
  $this->flush() ;
232
  $this->_conn = null ;
233
  self::$_instance = null ;
@@ -258,7 +258,7 @@ class LiteSpeed_Cache_Object
258
  return null ;
259
  }
260
 
261
- defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( 'Object: connecting to ' . $this->_cfg_host . ':' . $this->_cfg_port ) ;
262
 
263
  $failed = false ;
264
  /**
@@ -268,7 +268,7 @@ class LiteSpeed_Cache_Object
268
  * @see https://github.com/phpredis/phpredis/#example-1
269
  */
270
  if ( $this->_oc_driver == 'Redis' ) {
271
- defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( 'Object: Init ' . $this->_oc_driver . ' connection' ) ;
272
 
273
  set_error_handler( 'litespeed_exception_handler' ) ;
274
  try {
@@ -321,18 +321,18 @@ class LiteSpeed_Cache_Object
321
  * Connect to Memcached
322
  */
323
  else {
324
- defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( 'Object: Init ' . $this->_oc_driver . ' connection' ) ;
325
  if ( $this->_cfg_persistent ) {
326
  $this->_conn = new Memcached( $this->_get_mem_id() ) ;
327
 
328
  // Check memcached persistent connection
329
  if ( $this->_validate_mem_server() ) {
330
  // error_log( 'Object: _validate_mem_server' ) ;
331
- defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( 'Object: Got persistent ' . $this->_oc_driver . ' connection' ) ;
332
  return true ;
333
  }
334
 
335
- defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( 'Object: No persistent ' . $this->_oc_driver . ' server list!' ) ;
336
  }
337
  else {
338
  // error_log( 'Object: new memcached!' ) ;
@@ -357,14 +357,14 @@ class LiteSpeed_Cache_Object
357
 
358
  // If failed to connect
359
  if ( $failed ) {
360
- defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( 'Object: Failed to connect ' . $this->_oc_driver . ' server!' ) ;
361
  $this->_conn = null ;
362
  $this->_cfg_enabled = false ;
363
  // error_log( 'Object: false!' ) ;
364
  return false ;
365
  }
366
 
367
- defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug2( 'Object: Connected' ) ;
368
 
369
  return true ;
370
  }
@@ -430,7 +430,7 @@ class LiteSpeed_Cache_Object
430
  return null ;
431
  }
432
 
433
- // defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug2( 'Object: get ' . $key ) ;
434
 
435
  $res = $this->_conn->get( $key ) ;
436
 
@@ -457,7 +457,7 @@ class LiteSpeed_Cache_Object
457
  return null ;
458
  }
459
 
460
- // defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug2( 'Object: set ' . $key ) ;
461
 
462
  // error_log( 'Object: set ' . $key ) ;
463
 
@@ -503,7 +503,7 @@ class LiteSpeed_Cache_Object
503
  return null ;
504
  }
505
 
506
- // defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug2( 'Object: delete ' . $key ) ;
507
 
508
  $res = $this->_conn->delete( $key ) ;
509
 
@@ -519,7 +519,7 @@ class LiteSpeed_Cache_Object
519
  public function flush()
520
  {
521
  if ( ! $this->_cfg_enabled ) {
522
- defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( 'Object: bypass flushing' ) ;
523
  return null ;
524
  }
525
 
@@ -527,7 +527,7 @@ class LiteSpeed_Cache_Object
527
  return null ;
528
  }
529
 
530
- defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( 'Object: flush!' ) ;
531
 
532
  if ( $this->_oc_driver == 'Redis' ) {
533
  $res = $this->_conn->flushDb() ;
51
  */
52
  private function __construct( $cfg = false )
53
  {
54
+ defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug2( '[Object] init' ) ;
55
 
56
  $this->_oc_data_file = WP_CONTENT_DIR . '/.object-cache.ini' ;
57
 
74
  }
75
  $this->_cfg_enabled = $cfg[ LiteSpeed_Cache_Config::OPID_CACHE_OBJECT ] && class_exists( $this->_oc_driver ) && $this->_cfg_host ;
76
 
77
+ defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( '[Object] init with cfg result : ', $this->_cfg_enabled ) ;
78
  }
79
  elseif ( class_exists( 'LiteSpeed_Cache' ) ) {
80
  $this->_cfg_method = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_KIND ) ? true : false ;
174
 
175
  // Update cls file
176
  if ( ! file_exists( $wp_file ) || md5_file( $wp_file ) !== md5_file( $ori_file ) ) {
177
+ defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( '[Object] copying object-cache.php file to ' . $wp_file ) ;
178
  copy( $ori_file, $wp_file ) ;
179
  }
180
  }
181
  else {
182
  // To delete file
183
  if ( file_exists( $wp_file ) ) {
184
+ defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( '[Object] removing ' . $wp_file ) ;
185
  unlink( $wp_file ) ;
186
  }
187
  file_exists( $this->_oc_data_file ) && unlink( $this->_oc_data_file ) ;
223
  */
224
  public function reconnect( $cfg )
225
  {
226
+ defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( '[Object] Reconnecting' ) ;
227
  // error_log( 'Object: reconnect !' ) ;
228
  if ( isset( $this->_conn ) ) {
229
  // error_log( 'Object: Quiting existing connection!' ) ;
230
+ defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( '[Object] Quiting existing connection' ) ;
231
  $this->flush() ;
232
  $this->_conn = null ;
233
  self::$_instance = null ;
258
  return null ;
259
  }
260
 
261
+ defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( '[Object] connecting to ' . $this->_cfg_host . ':' . $this->_cfg_port ) ;
262
 
263
  $failed = false ;
264
  /**
268
  * @see https://github.com/phpredis/phpredis/#example-1
269
  */
270
  if ( $this->_oc_driver == 'Redis' ) {
271
+ defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( '[Object] Init ' . $this->_oc_driver . ' connection' ) ;
272
 
273
  set_error_handler( 'litespeed_exception_handler' ) ;
274
  try {
321
  * Connect to Memcached
322
  */
323
  else {
324
+ defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( '[Object] Init ' . $this->_oc_driver . ' connection' ) ;
325
  if ( $this->_cfg_persistent ) {
326
  $this->_conn = new Memcached( $this->_get_mem_id() ) ;
327
 
328
  // Check memcached persistent connection
329
  if ( $this->_validate_mem_server() ) {
330
  // error_log( 'Object: _validate_mem_server' ) ;
331
+ defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( '[Object] Got persistent ' . $this->_oc_driver . ' connection' ) ;
332
  return true ;
333
  }
334
 
335
+ defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( '[Object] No persistent ' . $this->_oc_driver . ' server list!' ) ;
336
  }
337
  else {
338
  // error_log( 'Object: new memcached!' ) ;
357
 
358
  // If failed to connect
359
  if ( $failed ) {
360
+ defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( '[Object] Failed to connect ' . $this->_oc_driver . ' server!' ) ;
361
  $this->_conn = null ;
362
  $this->_cfg_enabled = false ;
363
  // error_log( 'Object: false!' ) ;
364
  return false ;
365
  }
366
 
367
+ defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug2( '[Object] Connected' ) ;
368
 
369
  return true ;
370
  }
430
  return null ;
431
  }
432
 
433
+ // defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug2( '[Object] get ' . $key ) ;
434
 
435
  $res = $this->_conn->get( $key ) ;
436
 
457
  return null ;
458
  }
459
 
460
+ // defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug2( '[Object] set ' . $key ) ;
461
 
462
  // error_log( 'Object: set ' . $key ) ;
463
 
503
  return null ;
504
  }
505
 
506
+ // defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug2( '[Object] delete ' . $key ) ;
507
 
508
  $res = $this->_conn->delete( $key ) ;
509
 
519
  public function flush()
520
  {
521
  if ( ! $this->_cfg_enabled ) {
522
+ defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( '[Object] bypass flushing' ) ;
523
  return null ;
524
  }
525
 
527
  return null ;
528
  }
529
 
530
+ defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( '[Object] flush!' ) ;
531
 
532
  if ( $this->_oc_driver == 'Redis' ) {
533
  $res = $this->_conn->flushDb() ;
inc/optimize.class.php CHANGED
@@ -367,7 +367,7 @@ class LiteSpeed_Cache_Optimize
367
  // Check if hit URI excludes
368
  $excludes = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_EXCLUDES ) ;
369
  if ( ! empty( $excludes ) ) {
370
- $result = LiteSpeed_Cache_Utility::str_hit_array( esc_url( $_SERVER[ 'REQUEST_URI' ] ), explode( "\n", $excludes ) ) ;
371
  if ( $result ) {
372
  LiteSpeed_Cache_Log::debug( '[Optm] bypass: hit URI Excludes setting: ' . $result ) ;
373
  return $content ;
367
  // Check if hit URI excludes
368
  $excludes = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_EXCLUDES ) ;
369
  if ( ! empty( $excludes ) ) {
370
+ $result = LiteSpeed_Cache_Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], explode( "\n", $excludes ) ) ;
371
  if ( $result ) {
372
  LiteSpeed_Cache_Log::debug( '[Optm] bypass: hit URI Excludes setting: ' . $result ) ;
373
  return $content ;
inc/purge.class.php CHANGED
@@ -4,6 +4,7 @@
4
  *
5
  * @since 1.1.3
6
  * @since 1.5 Moved into /inc
 
7
  * @package LiteSpeed_Cache
8
  * @subpackage LiteSpeed_Cache/inc
9
  * @author LiteSpeed Technologies <info@litespeedtech.com>
@@ -11,16 +12,24 @@
11
  class LiteSpeed_Cache_Purge
12
  {
13
  private static $_instance ;
14
- protected static $_pub_purge = array() ;
15
- protected static $_priv_purge = array() ;
16
- protected static $_purge_related = false ;
17
- protected static $_purge_single = false ;
18
 
19
  const X_HEADER = 'X-LiteSpeed-Purge' ;
20
  const PURGE_QUEUE = 'litespeed-cache-purge-queue' ;
21
 
22
- const TYPE_OBJECT_PURGE_ALL = 'object_purge_all' ;
23
- const TYPE_OPCACHE_PURGE_ALL = 'opcache_purge_all' ;
 
 
 
 
 
 
 
 
24
 
25
  /**
26
  * Handle all request actions from main cls
@@ -35,12 +44,40 @@ class LiteSpeed_Cache_Purge
35
  $type = LiteSpeed_Cache_Router::verify_type() ;
36
 
37
  switch ( $type ) {
38
- case self::TYPE_OBJECT_PURGE_ALL :
39
- $instance->_object_purge_all() ;
 
 
 
 
 
 
 
 
40
  break ;
41
 
42
- case self::TYPE_OPCACHE_PURGE_ALL :
43
- $instance->_opcache_purge_all() ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  break ;
45
 
46
  default:
@@ -50,29 +87,106 @@ class LiteSpeed_Cache_Purge
50
  LiteSpeed_Cache_Admin::redirect() ;
51
  }
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  /**
54
  * Purge opcode cache
55
  *
56
  * @since 1.8.2
57
  * @access private
58
  */
59
- private function _opcache_purge_all()
60
  {
61
  if ( ! LiteSpeed_Cache_Router::opcache_enabled() ) {
62
- LiteSpeed_Cache_Log::debug( 'Purge: Failed to reset opcode cache due to opcache not enabled' ) ;
63
 
64
- $msg = __( 'Opcode cache is not enabled.', 'litespeed-cache' ) ;
65
- LiteSpeed_Cache_Admin_Display::error( $msg ) ;
 
 
66
 
67
  return false ;
68
  }
69
 
70
  // Purge opcode cache
71
  opcache_reset() ;
72
- LiteSpeed_Cache_Log::debug( 'Purge: Reset opcode cache' ) ;
73
 
74
- $msg = __( 'Reset the entire opcode cache successfully.', 'litespeed-cache' ) ;
75
- LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
 
 
76
 
77
  return true ;
78
  }
@@ -83,21 +197,25 @@ class LiteSpeed_Cache_Purge
83
  * @since 1.8
84
  * @access private
85
  */
86
- private function _object_purge_all()
87
  {
88
  if ( ! defined( 'LSCWP_OBJECT_CACHE' ) ) {
89
- LiteSpeed_Cache_Log::debug( 'Purge: Failed to flush object cache due to object cache not enabled' ) ;
90
 
91
- $msg = __( 'Object cache is not enabled.', 'litespeed-cache' ) ;
92
- LiteSpeed_Cache_Admin_Display::error( $msg ) ;
 
 
93
 
94
  return false ;
95
  }
96
  LiteSpeed_Cache_Object::get_instance()->flush() ;
97
- LiteSpeed_Cache_Log::debug( 'Purge: Flushed object cache' ) ;
98
 
99
- $msg = __( 'Purge all object caches successfully.', 'litespeed-cache' ) ;
100
- LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
 
 
101
 
102
  return true ;
103
  }
@@ -110,28 +228,40 @@ class LiteSpeed_Cache_Purge
110
  * @param mixed $tags Tags to add to the list.
111
  */
112
  public static function add( $tags )
 
 
 
 
 
 
 
 
 
 
 
113
  {
114
  if ( ! is_array( $tags ) ) {
115
  $tags = array( $tags ) ;
116
  }
117
- if ( ! array_diff( $tags, self::$_pub_purge ) ) {
118
  return ;
119
  }
120
 
121
- self::$_pub_purge = array_merge( self::$_pub_purge, $tags ) ;
122
- LiteSpeed_Cache_Log::debug( 'Purge: added ' . implode( ',', $tags ), 3 ) ;
123
 
124
  // Send purge header immediately
125
- $curr_built = self::_build() ;
126
  if ( defined( 'LITESPEED_DID_send_headers' ) ) {
127
  // Can't send, already has output, need to save and wait for next run
128
  update_option( self::PURGE_QUEUE, $curr_built ) ;
129
- LiteSpeed_Cache_Log::debug( 'Output existed, Purge queue stored: ' . $curr_built ) ;
130
  }
131
  else {
132
  @header( $curr_built ) ;
133
  LiteSpeed_Cache_Log::debug( $curr_built ) ;
134
  }
 
135
  }
136
 
137
  /**
@@ -142,20 +272,31 @@ class LiteSpeed_Cache_Purge
142
  * @param mixed $tags Tags to add to the list.
143
  */
144
  public static function add_private( $tags )
 
 
 
 
 
 
 
 
 
 
 
145
  {
146
  if ( ! is_array( $tags ) ) {
147
  $tags = array( $tags ) ;
148
  }
149
- if ( ! array_diff( $tags, self::$_priv_purge ) ) {
150
  return ;
151
  }
152
 
153
- LiteSpeed_Cache_Log::debug( 'Purge: added [private] ' . implode( ',', $tags ), 3 ) ;
154
 
155
- self::$_priv_purge = array_merge( self::$_priv_purge, $tags ) ;
156
 
157
  // Send purge header immediately
158
- @header( self::_build() ) ;
159
  }
160
 
161
  /**
@@ -166,7 +307,7 @@ class LiteSpeed_Cache_Purge
166
  */
167
  public static function set_purge_related()
168
  {
169
- self::$_purge_related = true ;
170
  }
171
 
172
  /**
@@ -177,94 +318,89 @@ class LiteSpeed_Cache_Purge
177
  */
178
  public static function set_purge_single()
179
  {
180
- self::$_purge_single = true ;
181
  }
182
 
183
  /**
184
- * Check qs purge status
185
  *
186
- * @since 1.1.3
187
  * @access public
188
  */
189
- public static function get_qs_purge()
190
  {
191
- return self::$_purge_single || self::$_purge_related ;
192
  }
193
 
194
  /**
195
- * Alerts LiteSpeed Web Server to purge all pages.
196
- *
197
- * For multisite installs, if this is called by a site admin (not network admin),
198
- * it will only purge all posts associated with that site.
199
  *
200
- * @since 1.0.0
201
- * @access public
 
202
  */
203
- public static function purge_all()
204
  {
205
- self::add( '*' ) ;
206
-
207
- // check if need to reset crawler
208
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE ) ) {
209
- LiteSpeed_Cache_Crawler::get_instance()->reset_pos() ;
210
  }
 
 
 
 
 
211
  }
212
 
213
  /**
214
  * Alerts LiteSpeed Web Server to purge the front page.
215
  *
216
  * @since 1.0.3
217
- * @access public
 
218
  */
219
- public static function purge_front()
220
  {
221
- self::add( LiteSpeed_Cache_Tag::TYPE_FRONTPAGE ) ;
222
  if ( LITESPEED_SERVER_TYPE !== 'LITESPEED_SERVER_OLS' ) {
223
- self::add_private( LiteSpeed_Cache_Tag::TYPE_FRONTPAGE ) ;
224
  }
225
- }
226
 
227
- /**
228
- * Alerts LiteSpeed Web Server to purge pages.
229
- *
230
- * @since 1.0.15
231
- * @access public
232
- */
233
- public static function purge_pages()
234
- {
235
- self::add( LiteSpeed_Cache_Tag::TYPE_PAGES ) ;
236
  }
237
 
238
  /**
239
  * Alerts LiteSpeed Web Server to purge pages.
240
  *
241
- * @since 1.2.2
242
- * @access public
243
  */
244
- public static function purge_cssjs()
245
  {
246
- self::add( LiteSpeed_Cache_Tag::TYPE_MIN ) ;
247
 
248
- // For non-ls users
249
- LiteSpeed_Cache_Optimize::get_instance()->rm_cache_folder() ;
250
  }
251
 
252
  /**
253
  * Alerts LiteSpeed Web Server to purge error pages.
254
  *
255
  * @since 1.0.14
256
- * @access public
257
  */
258
- public static function purge_errors()
259
  {
260
- self::add( LiteSpeed_Cache_Tag::TYPE_ERROR ) ;
261
 
262
- $type = LiteSpeed_Cache_Router::verify_type() ;
263
  if ( ! $type || ! in_array( $type, array( '403', '404', '500' ) ) ) {
264
  return ;
265
  }
266
 
267
- self::add( LiteSpeed_Cache_Tag::TYPE_ERROR . $type ) ;
 
 
 
268
  }
269
 
270
  /**
@@ -291,9 +427,9 @@ class LiteSpeed_Cache_Purge
291
  return ;
292
  }
293
 
294
- LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, sprintf( __( 'Purge category %s', 'litespeed-cache' ), $val ) ) ;
295
 
296
- self::add( LiteSpeed_Cache_Tag::TYPE_ARCHIVE_TERM . $cat->term_id ) ;
297
  }
298
 
299
  /**
@@ -318,9 +454,9 @@ class LiteSpeed_Cache_Purge
318
  LiteSpeed_Cache_Admin_Display::add_error( LiteSpeed_Cache_Admin_Error::E_PURGEBY_PID_DNE, $val ) ;
319
  return ;
320
  }
321
- LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, sprintf( __( 'Purge Post ID %s', 'litespeed-cache' ), $val ) ) ;
322
 
323
- self::add( LiteSpeed_Cache_Tag::TYPE_POST . $val ) ;
324
  }
325
 
326
  /**
@@ -347,9 +483,9 @@ class LiteSpeed_Cache_Purge
347
  return ;
348
  }
349
 
350
- LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, sprintf( __( 'Purge tag %s', 'litespeed-cache' ), $val ) ) ;
351
 
352
- self::add( LiteSpeed_Cache_Tag::TYPE_ARCHIVE_TERM . $term->term_id ) ;
353
  }
354
 
355
  /**
@@ -381,9 +517,9 @@ class LiteSpeed_Cache_Purge
381
  return ;
382
  }
383
 
384
- LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, sprintf( __( 'Purge url %s', 'litespeed-cache' ), $val ) ) ;
385
 
386
- self::add( $hash ) ;
387
  return ;
388
  }
389
 
@@ -425,29 +561,10 @@ class LiteSpeed_Cache_Purge
425
  LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_PURGEBY_BAD) ;
426
  return ;
427
  }
428
- array_walk($list, Array($this, $cb)) ;
429
 
430
  // for redirection
431
- $_GET[LiteSpeed_Cache_Admin_Display::PURGEBYOPT_SELECT] = $sel ;
432
- }
433
-
434
- /**
435
- * Purge frontend url
436
- *
437
- * @since 1.3
438
- * @access public
439
- */
440
- public static function frontend_purge()
441
- {
442
- if ( empty( $_SERVER[ 'HTTP_REFERER' ] ) ) {
443
- exit( 'no referer' ) ;
444
- }
445
- $instance = self::get_instance() ;
446
-
447
- $instance->purgeby_url_cb( $_SERVER[ 'HTTP_REFERER' ] ) ;
448
-
449
- wp_redirect( $_SERVER[ 'HTTP_REFERER' ] ) ;
450
- exit() ;
451
  }
452
 
453
  /**
@@ -468,17 +585,19 @@ class LiteSpeed_Cache_Purge
468
  return ;
469
  }
470
 
471
- $purge_tags = self::get_purge_tags_by_post($post_id) ;
 
 
472
  if ( empty($purge_tags) ) {
473
  return ;
474
  }
475
  if ( in_array( '*', $purge_tags ) ) {
476
- self::purge_all() ;
477
  }
478
  else {
479
- self::add( $purge_tags ) ;
480
  if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_REST ) ) {
481
- self::add( LiteSpeed_Cache_Tag::TYPE_REST ) ;
482
  }
483
  }
484
  LiteSpeed_Cache_Control::set_stale() ;
@@ -553,7 +672,7 @@ class LiteSpeed_Cache_Purge
553
  * @access private
554
  * @since 1.1.3
555
  */
556
- private static function _finalize()
557
  {
558
  // Make sure header output only run once
559
  if ( ! defined( 'LITESPEED_DID_' . __FUNCTION__ ) ) {
@@ -566,26 +685,26 @@ class LiteSpeed_Cache_Purge
566
  do_action('litespeed_cache_api_purge') ;
567
 
568
  // Append unique uri purge tags if Admin QS is `PURGESINGLE`
569
- if ( self::$_purge_single ) {
570
- self::$_pub_purge[] = LiteSpeed_Cache_Tag::build_uri_tag() ; // TODO: add private tag too
571
  }
572
  // Append related purge tags if Admin QS is `PURGE`
573
- if ( self::$_purge_related ) {
574
  // Before this, tags need to be finalized
575
  $tags_related = LiteSpeed_Cache_Tag::output_tags() ;
576
  // NOTE: need to remove the empty item `B1_` to avoid purging all
577
  $tags_related = array_filter($tags_related) ;
578
  if ( $tags_related ) {
579
- self::$_pub_purge = array_merge(self::$_pub_purge, $tags_related) ;
580
  }
581
  }
582
 
583
- if ( ! empty(self::$_pub_purge) ) {
584
- self::$_pub_purge = array_unique(self::$_pub_purge) ;
585
  }
586
 
587
- if ( ! empty(self::$_priv_purge) ) {
588
- self::$_priv_purge = array_unique(self::$_priv_purge) ;
589
  }
590
  }
591
 
@@ -600,9 +719,11 @@ class LiteSpeed_Cache_Purge
600
  */
601
  public static function output()
602
  {
603
- self::_finalize() ;
 
 
604
 
605
- return self::_build() ;
606
  }
607
 
608
  /**
@@ -612,17 +733,17 @@ class LiteSpeed_Cache_Purge
612
  * @access private
613
  * @return string the built purge header
614
  */
615
- private static function _build()
616
  {
617
- if ( empty( self::$_pub_purge ) && empty( self::$_priv_purge ) ) {
618
  return ;
619
  }
620
 
621
  $purge_header = '' ;
622
  $private_prefix = self::X_HEADER . ': private,' ;
623
 
624
- if ( ! empty( self::$_pub_purge ) ) {
625
- $public_tags = self::_append_prefix( self::$_pub_purge ) ;
626
  if ( empty( $public_tags ) ) {
627
  // If this ends up empty, private will also end up empty
628
  return ;
@@ -636,8 +757,8 @@ class LiteSpeed_Cache_Purge
636
  }
637
 
638
  // Handle priv purge tags
639
- if ( ! empty( self::$_priv_purge ) ) {
640
- $private_tags = self::_append_prefix( self::$_priv_purge, true ) ;
641
  $purge_header .= $private_prefix . implode( ',', $private_tags ) ;
642
  }
643
 
@@ -653,7 +774,7 @@ class LiteSpeed_Cache_Purge
653
  * @param boolean $is_private If is private tags or not.
654
  * @return array The array of built purge tags.
655
  */
656
- private static function _append_prefix( $purge_tags, $is_private = false )
657
  {
658
  $curr_bid = get_current_blog_id() ;
659
 
@@ -676,7 +797,7 @@ class LiteSpeed_Cache_Purge
676
  )) ) {
677
  $blogs = LiteSpeed_Cache_Activation::get_network_ids() ;
678
  if ( empty($blogs) ) {
679
- LiteSpeed_Cache_Log::debug('build_purge_headers: blog list is empty') ;
680
  return '' ;
681
  }
682
  $tags = array() ;
@@ -699,11 +820,11 @@ class LiteSpeed_Cache_Purge
699
  * any third party plugin specific post tags.
700
  *
701
  * @since 1.0.0
702
- * @access public
703
  * @param integer $post_id The id of the post about to be purged.
704
  * @return array The list of purge tags correlated with the post.
705
  */
706
- public static function get_purge_tags_by_post( $post_id )
707
  {
708
  // If this is a valid post we want to purge the post, the home page and any associated tags & cats
709
  // If not, purge everything on the site.
@@ -836,7 +957,7 @@ class LiteSpeed_Cache_Purge
836
  */
837
  public static function get_instance()
838
  {
839
- if ( ! isset(self::$_instance) ) {
840
  self::$_instance = new self() ;
841
  }
842
 
4
  *
5
  * @since 1.1.3
6
  * @since 1.5 Moved into /inc
7
+ * @since 2.2 Refactored. Changed access from public to private for most func and class variables.
8
  * @package LiteSpeed_Cache
9
  * @subpackage LiteSpeed_Cache/inc
10
  * @author LiteSpeed Technologies <info@litespeedtech.com>
12
  class LiteSpeed_Cache_Purge
13
  {
14
  private static $_instance ;
15
+ protected $_pub_purge = array() ;
16
+ protected $_priv_purge = array() ;
17
+ protected $_purge_related = false ;
18
+ protected $_purge_single = false ;
19
 
20
  const X_HEADER = 'X-LiteSpeed-Purge' ;
21
  const PURGE_QUEUE = 'litespeed-cache-purge-queue' ;
22
 
23
+ const TYPE_PURGE_ALL = 'purge_all' ;
24
+ const TYPE_PURGE_ALL_LSCACHE = 'purge_all_lscache' ;
25
+ const TYPE_PURGE_ALL_CSSJS = 'purge_all_cssjs' ;
26
+ const TYPE_PURGE_ALL_OBJECT = 'purge_all_object' ;
27
+ const TYPE_PURGE_ALL_OPCACHE = 'purge_all_opcache' ;
28
+
29
+ const TYPE_PURGE_FRONT = 'purge_front' ;
30
+ const TYPE_PURGE_FRONTPAGE = 'purge_frontpage' ;
31
+ const TYPE_PURGE_PAGES = 'purge_pages' ;
32
+ const TYPE_PURGE_ERROR = 'purge_error' ;
33
 
34
  /**
35
  * Handle all request actions from main cls
44
  $type = LiteSpeed_Cache_Router::verify_type() ;
45
 
46
  switch ( $type ) {
47
+ case self::TYPE_PURGE_ALL :
48
+ $instance->_purge_all() ;
49
+ break ;
50
+
51
+ case self::TYPE_PURGE_ALL_LSCACHE :
52
+ $instance->_purge_all_lscache() ;
53
+ break ;
54
+
55
+ case self::TYPE_PURGE_ALL_CSSJS :
56
+ $instance->_purge_all_cssjs() ;
57
  break ;
58
 
59
+ case self::TYPE_PURGE_ALL_OBJECT :
60
+ $instance->_purge_all_object() ;
61
+ break ;
62
+
63
+ case self::TYPE_PURGE_ALL_OPCACHE :
64
+ $instance->_purge_all_opcache() ;
65
+ break ;
66
+
67
+ case self::TYPE_PURGE_FRONT :
68
+ $instance->_purge_front() ;
69
+ break ;
70
+
71
+ case self::TYPE_PURGE_FRONTPAGE :
72
+ $instance->_purge_frontpage() ;
73
+ break ;
74
+
75
+ case self::TYPE_PURGE_PAGES :
76
+ $instance->_purge_pages() ;
77
+ break ;
78
+
79
+ case strpos( $type, self::TYPE_PURGE_ERROR ) === 0 :
80
+ $instance->_purge_error( substr( $type, strlen( self::TYPE_PURGE_ERROR ) ) ) ;
81
  break ;
82
 
83
  default:
87
  LiteSpeed_Cache_Admin::redirect() ;
88
  }
89
 
90
+ /**
91
+ * Shortcut to purge all lscache
92
+ *
93
+ * @since 1.0.0
94
+ * @access public
95
+ */
96
+ public static function purge_all( $reason = false )
97
+ {
98
+ self::get_instance()->_purge_all( $reason ) ;
99
+ }
100
+
101
+ /**
102
+ * Purge all caches (lscache/op/oc)
103
+ *
104
+ * @since 2.2
105
+ * @access private
106
+ */
107
+ private function _purge_all( $reason = false )
108
+ {
109
+ $this->_purge_all_lscache( true ) ;
110
+ $this->_purge_all_cssjs( true ) ;
111
+ $this->_purge_all_object( true ) ;
112
+ $this->_purge_all_opcache( true ) ;
113
+
114
+ LiteSpeed_Cache_Log::debug( '[Purge] Purge all' . ( $reason ? ' [Reason] ' . $reason : '' ), 3 ) ;
115
+
116
+ $msg = __( 'Purge all caches successfully.', 'litespeed-cache' ) ;
117
+ LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
118
+ }
119
+
120
+ /**
121
+ * Alerts LiteSpeed Web Server to purge all pages.
122
+ *
123
+ * For multisite installs, if this is called by a site admin (not network admin),
124
+ * it will only purge all posts associated with that site.
125
+ *
126
+ * @since 2.2
127
+ * @access public
128
+ */
129
+ private function _purge_all_lscache( $silence = false )
130
+ {
131
+ $this->_add( '*' ) ;
132
+
133
+ // check if need to reset crawler
134
+ if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE ) ) {
135
+ LiteSpeed_Cache_Crawler::get_instance()->reset_pos() ;
136
+ }
137
+
138
+ if ( ! $silence ) {
139
+ $msg = __( 'Notified LiteSpeed Web Server to purge all LSCache entries.', 'litespeed-cache' ) ;
140
+ LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
141
+ }
142
+ }
143
+
144
+ /**
145
+ * Alerts LiteSpeed Web Server to purge pages.
146
+ *
147
+ * @since 1.2.2
148
+ * @access private
149
+ */
150
+ private function _purge_all_cssjs( $silence = false )
151
+ {
152
+ $this->_add( LiteSpeed_Cache_Tag::TYPE_MIN ) ;
153
+
154
+ // For non-ls users
155
+ LiteSpeed_Cache_Optimize::get_instance()->rm_cache_folder() ;
156
+
157
+ if ( ! $silence ) {
158
+ $msg = __( 'Notified LiteSpeed Web Server to purge CSS/JS entries.', 'litespeed-cache' ) ;
159
+ LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
160
+ }
161
+ }
162
+
163
  /**
164
  * Purge opcode cache
165
  *
166
  * @since 1.8.2
167
  * @access private
168
  */
169
+ private function _purge_all_opcache( $silence = false )
170
  {
171
  if ( ! LiteSpeed_Cache_Router::opcache_enabled() ) {
172
+ LiteSpeed_Cache_Log::debug( '[Purge] Failed to reset opcode cache due to opcache not enabled' ) ;
173
 
174
+ if ( ! $silence ) {
175
+ $msg = __( 'Opcode cache is not enabled.', 'litespeed-cache' ) ;
176
+ LiteSpeed_Cache_Admin_Display::error( $msg ) ;
177
+ }
178
 
179
  return false ;
180
  }
181
 
182
  // Purge opcode cache
183
  opcache_reset() ;
184
+ LiteSpeed_Cache_Log::debug( '[Purge] Reset opcode cache' ) ;
185
 
186
+ if ( ! $silence ) {
187
+ $msg = __( 'Reset the entire opcode cache successfully.', 'litespeed-cache' ) ;
188
+ LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
189
+ }
190
 
191
  return true ;
192
  }
197
  * @since 1.8
198
  * @access private
199
  */
200
+ private function _purge_all_object( $silence = false )
201
  {
202
  if ( ! defined( 'LSCWP_OBJECT_CACHE' ) ) {
203
+ LiteSpeed_Cache_Log::debug( '[Purge] Failed to flush object cache due to object cache not enabled' ) ;
204
 
205
+ if ( ! $silence ) {
206
+ $msg = __( 'Object cache is not enabled.', 'litespeed-cache' ) ;
207
+ LiteSpeed_Cache_Admin_Display::error( $msg ) ;
208
+ }
209
 
210
  return false ;
211
  }
212
  LiteSpeed_Cache_Object::get_instance()->flush() ;
213
+ LiteSpeed_Cache_Log::debug( '[Purge] Flushed object cache' ) ;
214
 
215
+ if ( ! $silence ) {
216
+ $msg = __( 'Purge all object caches successfully.', 'litespeed-cache' ) ;
217
+ LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
218
+ }
219
 
220
  return true ;
221
  }
228
  * @param mixed $tags Tags to add to the list.
229
  */
230
  public static function add( $tags )
231
+ {
232
+ self::get_instance()->_add( $tags ) ;
233
+ }
234
+
235
+ /**
236
+ * Add tags to purge
237
+ *
238
+ * @since 2.2
239
+ * @access private
240
+ */
241
+ private function _add( $tags )
242
  {
243
  if ( ! is_array( $tags ) ) {
244
  $tags = array( $tags ) ;
245
  }
246
+ if ( ! array_diff( $tags, $this->_pub_purge ) ) {
247
  return ;
248
  }
249
 
250
+ $this->_pub_purge = array_merge( $this->_pub_purge, $tags ) ;
251
+ LiteSpeed_Cache_Log::debug( '[Purge] added ' . implode( ',', $tags ), 3 ) ;
252
 
253
  // Send purge header immediately
254
+ $curr_built = $this->_build() ;
255
  if ( defined( 'LITESPEED_DID_send_headers' ) ) {
256
  // Can't send, already has output, need to save and wait for next run
257
  update_option( self::PURGE_QUEUE, $curr_built ) ;
258
+ LiteSpeed_Cache_Log::debug( '[Purge] Output existed, queue stored: ' . $curr_built ) ;
259
  }
260
  else {
261
  @header( $curr_built ) ;
262
  LiteSpeed_Cache_Log::debug( $curr_built ) ;
263
  }
264
+
265
  }
266
 
267
  /**
272
  * @param mixed $tags Tags to add to the list.
273
  */
274
  public static function add_private( $tags )
275
+ {
276
+ self::get_instance()->_add_private( $tags ) ;
277
+ }
278
+
279
+ /**
280
+ * Add tags to private purge
281
+ *
282
+ * @since 2.2
283
+ * @access private
284
+ */
285
+ private function _add_private( $tags )
286
  {
287
  if ( ! is_array( $tags ) ) {
288
  $tags = array( $tags ) ;
289
  }
290
+ if ( ! array_diff( $tags, $this->_priv_purge ) ) {
291
  return ;
292
  }
293
 
294
+ LiteSpeed_Cache_Log::debug( '[Purge] added [private] ' . implode( ',', $tags ), 3 ) ;
295
 
296
+ $this->_priv_purge = array_merge( $this->_priv_purge, $tags ) ;
297
 
298
  // Send purge header immediately
299
+ @header( $this->_build() ) ;
300
  }
301
 
302
  /**
307
  */
308
  public static function set_purge_related()
309
  {
310
+ self::get_instance()->_purge_related = true ;
311
  }
312
 
313
  /**
318
  */
319
  public static function set_purge_single()
320
  {
321
+ self::get_instance()->_purge_single = true ;
322
  }
323
 
324
  /**
325
+ * Called from cfg::frontend_save() to purge front page
326
  *
327
+ * @since 2.2
328
  * @access public
329
  */
330
+ public static function purge_front()
331
  {
332
+ self::get_instance()->_purge_front() ;
333
  }
334
 
335
  /**
336
+ * Purge frontend url
 
 
 
337
  *
338
+ * @since 1.3
339
+ * @since 2.2 Renamed from `frontend_purge`; Access changed from public
340
+ * @access private
341
  */
342
+ private function _purge_front()
343
  {
344
+ if ( empty( $_SERVER[ 'HTTP_REFERER' ] ) ) {
345
+ exit( 'no referer' ) ;
 
 
 
346
  }
347
+
348
+ $this->purgeby_url_cb( $_SERVER[ 'HTTP_REFERER' ] ) ;
349
+
350
+ wp_redirect( $_SERVER[ 'HTTP_REFERER' ] ) ;
351
+ exit() ;
352
  }
353
 
354
  /**
355
  * Alerts LiteSpeed Web Server to purge the front page.
356
  *
357
  * @since 1.0.3
358
+ * @since 2.2 Access changed from public to private, renamed from `_purge_front`
359
+ * @access private
360
  */
361
+ private function _purge_frontpage()
362
  {
363
+ $this->_add( LiteSpeed_Cache_Tag::TYPE_FRONTPAGE ) ;
364
  if ( LITESPEED_SERVER_TYPE !== 'LITESPEED_SERVER_OLS' ) {
365
+ $this->_add_private( LiteSpeed_Cache_Tag::TYPE_FRONTPAGE ) ;
366
  }
 
367
 
368
+ $msg = __( 'Notified LiteSpeed Web Server to purge the front page.', 'litespeed-cache' ) ;
369
+ LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
 
 
 
 
 
 
 
370
  }
371
 
372
  /**
373
  * Alerts LiteSpeed Web Server to purge pages.
374
  *
375
+ * @since 1.0.15
376
+ * @access private
377
  */
378
+ private function _purge_pages()
379
  {
380
+ $this->_add( LiteSpeed_Cache_Tag::TYPE_PAGES ) ;
381
 
382
+ $msg = __( 'Notified LiteSpeed Web Server to purge pages.', 'litespeed-cache' ) ;
383
+ LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
384
  }
385
 
386
  /**
387
  * Alerts LiteSpeed Web Server to purge error pages.
388
  *
389
  * @since 1.0.14
390
+ * @access private
391
  */
392
+ private function _purge_error( $type = false )
393
  {
394
+ $this->_add( LiteSpeed_Cache_Tag::TYPE_ERROR ) ;
395
 
 
396
  if ( ! $type || ! in_array( $type, array( '403', '404', '500' ) ) ) {
397
  return ;
398
  }
399
 
400
+ $this->_add( LiteSpeed_Cache_Tag::TYPE_ERROR . $type ) ;
401
+
402
+ $msg = __( 'Notified LiteSpeed Web Server to purge error pages.', 'litespeed-cache' ) ;
403
+ LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
404
  }
405
 
406
  /**
427
  return ;
428
  }
429
 
430
+ LiteSpeed_Cache_Admin_Display::succeed( sprintf( __( 'Purge category %s', 'litespeed-cache' ), $val ) ) ;
431
 
432
+ $this->_add( LiteSpeed_Cache_Tag::TYPE_ARCHIVE_TERM . $cat->term_id ) ;
433
  }
434
 
435
  /**
454
  LiteSpeed_Cache_Admin_Display::add_error( LiteSpeed_Cache_Admin_Error::E_PURGEBY_PID_DNE, $val ) ;
455
  return ;
456
  }
457
+ LiteSpeed_Cache_Admin_Display::succeed( sprintf( __( 'Purge Post ID %s', 'litespeed-cache' ), $val ) ) ;
458
 
459
+ $this->_add( LiteSpeed_Cache_Tag::TYPE_POST . $val ) ;
460
  }
461
 
462
  /**
483
  return ;
484
  }
485
 
486
+ LiteSpeed_Cache_Admin_Display::succeed( sprintf( __( 'Purge tag %s', 'litespeed-cache' ), $val ) ) ;
487
 
488
+ $this->_add( LiteSpeed_Cache_Tag::TYPE_ARCHIVE_TERM . $term->term_id ) ;
489
  }
490
 
491
  /**
517
  return ;
518
  }
519
 
520
+ LiteSpeed_Cache_Admin_Display::succeed( sprintf( __( 'Purge url %s', 'litespeed-cache' ), $val ) ) ;
521
 
522
+ $this->_add( $hash ) ;
523
  return ;
524
  }
525
 
561
  LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_PURGEBY_BAD) ;
562
  return ;
563
  }
564
+ array_walk( $list, array( $this, $cb ) ) ;
565
 
566
  // for redirection
567
+ $_GET[ LiteSpeed_Cache_Admin_Display::PURGEBYOPT_SELECT ] = $sel ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
568
  }
569
 
570
  /**
585
  return ;
586
  }
587
 
588
+ $instance = self::get_instance() ;
589
+
590
+ $purge_tags = $instance->_get_purge_tags_by_post($post_id) ;
591
  if ( empty($purge_tags) ) {
592
  return ;
593
  }
594
  if ( in_array( '*', $purge_tags ) ) {
595
+ $instance->_purge_all_lscache() ;
596
  }
597
  else {
598
+ $instance->_add( $purge_tags ) ;
599
  if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_REST ) ) {
600
+ $instance->_add( LiteSpeed_Cache_Tag::TYPE_REST ) ;
601
  }
602
  }
603
  LiteSpeed_Cache_Control::set_stale() ;
672
  * @access private
673
  * @since 1.1.3
674
  */
675
+ private function _finalize()
676
  {
677
  // Make sure header output only run once
678
  if ( ! defined( 'LITESPEED_DID_' . __FUNCTION__ ) ) {
685
  do_action('litespeed_cache_api_purge') ;
686
 
687
  // Append unique uri purge tags if Admin QS is `PURGESINGLE`
688
+ if ( $this->_purge_single ) {
689
+ $this->_pub_purge[] = LiteSpeed_Cache_Tag::build_uri_tag() ; // TODO: add private tag too
690
  }
691
  // Append related purge tags if Admin QS is `PURGE`
692
+ if ( $this->_purge_related ) {
693
  // Before this, tags need to be finalized
694
  $tags_related = LiteSpeed_Cache_Tag::output_tags() ;
695
  // NOTE: need to remove the empty item `B1_` to avoid purging all
696
  $tags_related = array_filter($tags_related) ;
697
  if ( $tags_related ) {
698
+ $this->_pub_purge = array_merge($this->_pub_purge, $tags_related) ;
699
  }
700
  }
701
 
702
+ if ( ! empty($this->_pub_purge) ) {
703
+ $this->_pub_purge = array_unique($this->_pub_purge) ;
704
  }
705
 
706
+ if ( ! empty($this->_priv_purge) ) {
707
+ $this->_priv_purge = array_unique($this->_priv_purge) ;
708
  }
709
  }
710
 
719
  */
720
  public static function output()
721
  {
722
+ $instance = self::get_instance() ;
723
+
724
+ $instance->_finalize() ;
725
 
726
+ return $instance->_build() ;
727
  }
728
 
729
  /**
733
  * @access private
734
  * @return string the built purge header
735
  */
736
+ private function _build()
737
  {
738
+ if ( empty( $this->_pub_purge ) && empty( $this->_priv_purge ) ) {
739
  return ;
740
  }
741
 
742
  $purge_header = '' ;
743
  $private_prefix = self::X_HEADER . ': private,' ;
744
 
745
+ if ( ! empty( $this->_pub_purge ) ) {
746
+ $public_tags = $this->_append_prefix( $this->_pub_purge ) ;
747
  if ( empty( $public_tags ) ) {
748
  // If this ends up empty, private will also end up empty
749
  return ;
757
  }
758
 
759
  // Handle priv purge tags
760
+ if ( ! empty( $this->_priv_purge ) ) {
761
+ $private_tags = $this->_append_prefix( $this->_priv_purge, true ) ;
762
  $purge_header .= $private_prefix . implode( ',', $private_tags ) ;
763
  }
764
 
774
  * @param boolean $is_private If is private tags or not.
775
  * @return array The array of built purge tags.
776
  */
777
+ private function _append_prefix( $purge_tags, $is_private = false )
778
  {
779
  $curr_bid = get_current_blog_id() ;
780
 
797
  )) ) {
798
  $blogs = LiteSpeed_Cache_Activation::get_network_ids() ;
799
  if ( empty($blogs) ) {
800
+ LiteSpeed_Cache_Log::debug('[Purge] build_purge_headers: blog list is empty') ;
801
  return '' ;
802
  }
803
  $tags = array() ;
820
  * any third party plugin specific post tags.
821
  *
822
  * @since 1.0.0
823
+ * @access private
824
  * @param integer $post_id The id of the post about to be purged.
825
  * @return array The list of purge tags correlated with the post.
826
  */
827
+ private function _get_purge_tags_by_post( $post_id )
828
  {
829
  // If this is a valid post we want to purge the post, the home page and any associated tags & cats
830
  // If not, purge everything on the site.
957
  */
958
  public static function get_instance()
959
  {
960
+ if ( ! isset( self::$_instance ) ) {
961
  self::$_instance = new self() ;
962
  }
963
 
inc/router.class.php CHANGED
@@ -346,31 +346,20 @@ class LiteSpeed_Cache_Router
346
  }
347
  return ;
348
 
349
- case LiteSpeed_Cache::ACTION_PURGE_FRONT:
350
- case LiteSpeed_Cache::ACTION_PURGE_PAGES:
351
- case LiteSpeed_Cache::ACTION_PURGE_ERRORS:
352
- case LiteSpeed_Cache::ACTION_PURGE_ALL:
353
  case LiteSpeed_Cache::ACTION_PURGE_BY:
354
- case LiteSpeed_Cache::ACTION_FRONT_PURGE:
355
  case LiteSpeed_Cache::ACTION_FRONT_EXCLUDE:
356
  if ( defined( 'LITESPEED_ON' ) && ( $_can_network_option || $_can_option || self::is_ajax() ) ) {//here may need more security
357
  self::$_action = $action ;
358
  }
359
  return ;
360
 
361
- case LiteSpeed_Cache::ACTION_PURGE_CSSJS: // will clear non-ls users file-based cache folder too
362
- if ( $_can_network_option || $_can_option || self::is_ajax() ) {
363
- self::$_action = $action ;
364
- }
365
- return ;
366
-
367
  case LiteSpeed_Cache::ACTION_DB_OPTIMIZE:
368
  if ( $_can_network_option || $_can_option ) {
369
  self::$_action = $action ;
370
  }
371
  return ;
372
 
373
- case LiteSpeed_Cache::ACTION_PURGE_EMPTYCACHE:
374
  if ( defined( 'LITESPEED_ON' ) && ( $_can_network_option || ( ! $_is_multisite && $_can_option ) ) ) {
375
  self::$_action = $action ;
376
  }
346
  }
347
  return ;
348
 
 
 
 
 
349
  case LiteSpeed_Cache::ACTION_PURGE_BY:
 
350
  case LiteSpeed_Cache::ACTION_FRONT_EXCLUDE:
351
  if ( defined( 'LITESPEED_ON' ) && ( $_can_network_option || $_can_option || self::is_ajax() ) ) {//here may need more security
352
  self::$_action = $action ;
353
  }
354
  return ;
355
 
 
 
 
 
 
 
356
  case LiteSpeed_Cache::ACTION_DB_OPTIMIZE:
357
  if ( $_can_network_option || $_can_option ) {
358
  self::$_action = $action ;
359
  }
360
  return ;
361
 
362
+ case LiteSpeed_Cache::ACTION_PURGE_EMPTYCACHE:// todo: moved to purge.cls type action
363
  if ( defined( 'LITESPEED_ON' ) && ( $_can_network_option || ( ! $_is_multisite && $_can_option ) ) ) {
364
  self::$_action = $action ;
365
  }
includes/litespeed-cache-api.class.php CHANGED
@@ -114,6 +114,28 @@ class LiteSpeed_Cache_API
114
  LiteSpeed_Cache_Control::set_nocache( $reason ?: 'api' ) ;
115
  }
116
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  /**
118
  * Get current not cacheable status
119
  *
114
  LiteSpeed_Cache_Control::set_nocache( $reason ?: 'api' ) ;
115
  }
116
 
117
+ /**
118
+ * Set cache status to cacheable ( By default cacheable status will be set when called WP hook `wp` )
119
+ *
120
+ * @since 2.2
121
+ * @access public
122
+ */
123
+ public static function set_cacheable( $reason )
124
+ {
125
+ LiteSpeed_Cache_Control::set_cacheable( $reason ) ;
126
+ }
127
+
128
+ /**
129
+ * Set cache status to force cacheable ( Will ignore most kinds of non-cacheable conditions )
130
+ *
131
+ * @since 2.2
132
+ * @access public
133
+ */
134
+ public static function set_force_cacheable( $reason )
135
+ {
136
+ LiteSpeed_Cache_Control::force_cacheable( $reason ) ;
137
+ }
138
+
139
  /**
140
  * Get current not cacheable status
141
  *
includes/litespeed-cache-config.class.php CHANGED
@@ -95,6 +95,7 @@ class LiteSpeed_Cache_Config
95
  // do NOT set default options for these three, it is used for admin.
96
  const ID_NOCACHE_COOKIES = 'nocache_cookies' ;
97
  const ID_NOCACHE_USERAGENTS = 'nocache_useragents' ;
 
98
  const OPID_DEBUG = 'debug' ;
99
  const OPID_ADMIN_IPS = 'admin_ips' ;
100
  const OPID_DEBUG_LEVEL = 'debug_level' ;
@@ -126,6 +127,7 @@ class LiteSpeed_Cache_Config
126
  const PURGE_DATE = 'D' ;
127
  const PURGE_TERM = 'T' ; // include category|tag|tax
128
  const PURGE_POST_TYPE = 'PT' ;
 
129
  const OPID_EXCLUDES_URI = 'excludes_uri' ;
130
  const OPID_EXCLUDES_QS = 'excludes_qs' ;
131
  const OPID_EXCLUDES_CAT = 'excludes_cat' ;
@@ -419,6 +421,10 @@ class LiteSpeed_Cache_Config
419
  }
420
 
421
  switch ( $type ) {
 
 
 
 
422
  case 'private' :
423
  $id = self::OPID_CACHE_URI_PRIV ;
424
  break ;
@@ -446,7 +452,7 @@ class LiteSpeed_Cache_Config
446
  $instance->update_options( array( $id => $list ) ) ;
447
 
448
  // Purge this page & redirect
449
- LiteSpeed_Cache_Purge::frontend_purge() ;
450
  exit() ;
451
  }
452
 
@@ -606,6 +612,7 @@ class LiteSpeed_Cache_Config
606
  self::OPID_LOGIN_COOKIE => '',
607
  self::OPID_CHECK_ADVANCEDCACHE => true,
608
  self::OPID_USE_HTTP_FOR_HTTPS_VARY => false,
 
609
  self::OPID_DEBUG => self::LOG_LEVEL_NONE,
610
  self::OPID_ADMIN_IPS => '127.0.0.1',
611
  self::OPID_DEBUG_LEVEL => false,
@@ -622,6 +629,7 @@ class LiteSpeed_Cache_Config
622
  self::OPID_404_TTL => 3600,
623
  self::OPID_500_TTL => 3600,
624
  self::OPID_PURGE_BY_POST => implode('.', $default_purge_options),
 
625
  self::OPID_EXCLUDES_URI => '',
626
  self::OPID_EXCLUDES_QS => '',
627
  self::OPID_EXCLUDES_CAT => '',
95
  // do NOT set default options for these three, it is used for admin.
96
  const ID_NOCACHE_COOKIES = 'nocache_cookies' ;
97
  const ID_NOCACHE_USERAGENTS = 'nocache_useragents' ;
98
+ const OPID_DEBUG_DISABLE_ALL = 'debug_disable_all' ;
99
  const OPID_DEBUG = 'debug' ;
100
  const OPID_ADMIN_IPS = 'admin_ips' ;
101
  const OPID_DEBUG_LEVEL = 'debug_level' ;
127
  const PURGE_DATE = 'D' ;
128
  const PURGE_TERM = 'T' ; // include category|tag|tax
129
  const PURGE_POST_TYPE = 'PT' ;
130
+ const OPID_FORCE_CACHE_URI = 'forced_cache_uri' ;
131
  const OPID_EXCLUDES_URI = 'excludes_uri' ;
132
  const OPID_EXCLUDES_QS = 'excludes_qs' ;
133
  const OPID_EXCLUDES_CAT = 'excludes_cat' ;
421
  }
422
 
423
  switch ( $type ) {
424
+ case 'forced_cache' :
425
+ $id = self::OPID_FORCE_CACHE_URI ;
426
+ break ;
427
+
428
  case 'private' :
429
  $id = self::OPID_CACHE_URI_PRIV ;
430
  break ;
452
  $instance->update_options( array( $id => $list ) ) ;
453
 
454
  // Purge this page & redirect
455
+ LiteSpeed_Cache_Purge::purge_front() ;
456
  exit() ;
457
  }
458
 
612
  self::OPID_LOGIN_COOKIE => '',
613
  self::OPID_CHECK_ADVANCEDCACHE => true,
614
  self::OPID_USE_HTTP_FOR_HTTPS_VARY => false,
615
+ self::OPID_DEBUG_DISABLE_ALL => false,
616
  self::OPID_DEBUG => self::LOG_LEVEL_NONE,
617
  self::OPID_ADMIN_IPS => '127.0.0.1',
618
  self::OPID_DEBUG_LEVEL => false,
629
  self::OPID_404_TTL => 3600,
630
  self::OPID_500_TTL => 3600,
631
  self::OPID_PURGE_BY_POST => implode('.', $default_purge_options),
632
+ self::OPID_FORCE_CACHE_URI => '',
633
  self::OPID_EXCLUDES_URI => '',
634
  self::OPID_EXCLUDES_QS => '',
635
  self::OPID_EXCLUDES_CAT => '',
includes/litespeed-cache-control.class.php CHANGED
@@ -16,6 +16,7 @@ class LiteSpeed_Cache_Control
16
  const BM_PRIVATE = 2 ;
17
  const BM_SHARED = 4 ;
18
  const BM_NO_VARY = 8 ;
 
19
  const BM_PUBLIC_FORCED = 64 ;
20
  const BM_STALE = 128 ;
21
  const BM_NOTCACHEABLE = 256 ;
@@ -78,7 +79,7 @@ class LiteSpeed_Cache_Control
78
  // NOTE: If any strange resource doesn't use normal WP logic `wp_loaded` hook, rewrite rule can handle it
79
  $cache_res = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_RES ) ;
80
  if ( $cache_res ) {
81
- $uri = esc_url( $_SERVER["REQUEST_URI"] ) ;
82
  $pattern = '!' . LSCWP_CONTENT_FOLDER . LiteSpeed_Cache_Admin_Rules::RW_PATTERN_RES . '!' ;
83
  if ( preg_match( $pattern, $uri ) ) {
84
  add_action( 'wp_loaded', 'LiteSpeed_Cache_Control::set_cacheable', 5 ) ;
@@ -238,10 +239,34 @@ class LiteSpeed_Cache_Control
238
  * @access public
239
  * @since 1.1.3
240
  */
241
- public static function set_cacheable()
242
  {
243
  self::$_control |= self::BM_CACHEABLE ;
244
- LiteSpeed_Cache_Log::debug( '[Ctrl] X Cache_control init on' ) ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245
  }
246
 
247
  /**
@@ -272,6 +297,17 @@ class LiteSpeed_Cache_Control
272
  return self::$_control & self::BM_NOTCACHEABLE ;
273
  }
274
 
 
 
 
 
 
 
 
 
 
 
 
275
  /**
276
  * Check current cacheable status
277
  *
@@ -281,12 +317,14 @@ class LiteSpeed_Cache_Control
281
  */
282
  public static function is_cacheable()
283
  {
 
 
 
 
 
284
  return ! self::isset_notcacheable() && self::$_control & self::BM_CACHEABLE ;
285
  }
286
 
287
-
288
-
289
-
290
  /**
291
  * Set a custom TTL to use with the request if needed.
292
  *
@@ -448,6 +486,16 @@ class LiteSpeed_Cache_Control
448
  */
449
  public static function finalize()
450
  {
 
 
 
 
 
 
 
 
 
 
451
  // if is not cacheable, terminate check
452
  // Even no need to run 3rd party hook
453
  if ( ! self::is_cacheable() ) {
@@ -507,7 +555,7 @@ class LiteSpeed_Cache_Control
507
  return ;
508
  }
509
 
510
- if ( isset($_SERVER['LSCACHE_VARY_VALUE']) && $_SERVER['LSCACHE_VARY_VALUE'] === 'ismobile' ) {
511
  if ( ! wp_is_mobile() && ! self::is_mobile() ) {
512
  self::set_nocache( 'is not mobile' ) ;
513
  return ;
@@ -562,66 +610,65 @@ class LiteSpeed_Cache_Control
562
  // Check private cache URI setting
563
  $excludes = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_URI_PRIV ) ;
564
  if ( ! empty( $excludes ) ) {
565
- $uri = esc_url( $_SERVER[ 'REQUEST_URI' ] ) ;
566
- $result = LiteSpeed_Cache_Utility::str_hit_array( $uri, explode( "\n", $excludes ) ) ;
567
  if ( $result ) {
568
  self::set_private( 'Admin cfg Private Cached URI: ' . $result ) ;
569
  }
570
  }
571
 
572
- // Check if URI is excluded from cache
573
- $excludes = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_EXCLUDES_URI ) ;
574
- if ( ! empty( $excludes ) ) {
575
- $uri = esc_url( $_SERVER[ 'REQUEST_URI' ] ) ;
576
- $result = LiteSpeed_Cache_Utility::str_hit_array( $uri, explode( "\n", $excludes ) ) ;
577
- if ( $result ) {
578
- return $this->_no_cache_for( 'Admin configured URI Do not cache: ' . $result ) ;
 
 
579
  }
580
- }
581
 
582
- // Check QS excluded setting
583
- $excludes = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_EXCLUDES_QS ) ;
584
- if ( ! empty( $excludes ) && $qs = $this->_is_qs_excluded( explode( "\n", $excludes ) ) ) {
585
- return $this->_no_cache_for( 'Admin configured QS Do not cache: ' . $qs ) ;
586
- }
587
 
588
- $excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::OPID_EXCLUDES_CAT) ;
589
- if ( ! empty($excludes) && has_category(explode(',', $excludes)) ) {
590
- return $this->_no_cache_for('Admin configured Category Do not cache.') ;
591
- }
592
 
593
- $excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::OPID_EXCLUDES_TAG) ;
594
- if ( ! empty($excludes) && has_tag(explode(',', $excludes)) ) {
595
- return $this->_no_cache_for('Admin configured Tag Do not cache.') ;
596
- }
597
 
598
- $excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::ID_NOCACHE_COOKIES) ;
599
- if ( ! empty($excludes) && ! empty($_COOKIE) ) {
600
- $exclude_list = explode('|', $excludes) ;
601
 
602
- foreach( $_COOKIE as $key=>$val) {
603
- if ( in_array($key, $exclude_list) ) {
604
- return $this->_no_cache_for('Admin configured Cookie Do not cache.') ;
 
605
  }
606
  }
607
- }
608
 
609
- $excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::ID_NOCACHE_USERAGENTS) ;
610
- if ( ! empty($excludes) && isset($_SERVER['HTTP_USER_AGENT']) ) {
611
- $pattern = '/' . $excludes . '/' ;
612
- $nummatches = preg_match($pattern, $_SERVER['HTTP_USER_AGENT']) ;
613
- if ( $nummatches ) {
614
- return $this->_no_cache_for('Admin configured User Agent Do not cache.') ;
 
615
  }
616
- }
617
 
618
- // Check if is exclude roles ( Need to set Vary too )
619
- if ( $result = LiteSpeed_Cache_Config::get_instance()->in_exclude_cache_roles() ) {
620
- return $this->_no_cache_for( 'Role Excludes setting ' . $result ) ;
 
621
  }
622
 
623
-
624
-
625
  return true ;
626
  }
627
 
16
  const BM_PRIVATE = 2 ;
17
  const BM_SHARED = 4 ;
18
  const BM_NO_VARY = 8 ;
19
+ const BM_FORCED_CACHEABLE = 32 ;
20
  const BM_PUBLIC_FORCED = 64 ;
21
  const BM_STALE = 128 ;
22
  const BM_NOTCACHEABLE = 256 ;
79
  // NOTE: If any strange resource doesn't use normal WP logic `wp_loaded` hook, rewrite rule can handle it
80
  $cache_res = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_RES ) ;
81
  if ( $cache_res ) {
82
+ $uri = esc_url( $_SERVER["REQUEST_URI"] ) ;// todo: check if need esc_url()
83
  $pattern = '!' . LSCWP_CONTENT_FOLDER . LiteSpeed_Cache_Admin_Rules::RW_PATTERN_RES . '!' ;
84
  if ( preg_match( $pattern, $uri ) ) {
85
  add_action( 'wp_loaded', 'LiteSpeed_Cache_Control::set_cacheable', 5 ) ;
239
  * @access public
240
  * @since 1.1.3
241
  */
242
+ public static function set_cacheable( $reason = false )
243
  {
244
  self::$_control |= self::BM_CACHEABLE ;
245
+
246
+ if ( ! is_string( $reason ) ) {
247
+ $reason = false ;
248
+ }
249
+
250
+ if ( $reason ) {
251
+ $reason = ' [reason] ' . $reason ;
252
+ }
253
+ LiteSpeed_Cache_Log::debug( '[Ctrl] X Cache_control init on' . $reason ) ;
254
+ }
255
+
256
+ /**
257
+ * This will disable non-cacheable BM
258
+ *
259
+ * @access public
260
+ * @since 2.2
261
+ */
262
+ public static function force_cacheable( $reason = false )
263
+ {
264
+ self::$_control |= self::BM_FORCED_CACHEABLE ;
265
+
266
+ if ( $reason ) {
267
+ $reason = ' [reason] ' . $reason ;
268
+ }
269
+ LiteSpeed_Cache_Log::debug( '[Ctrl] Forced cacheable' . $reason ) ;
270
  }
271
 
272
  /**
297
  return self::$_control & self::BM_NOTCACHEABLE ;
298
  }
299
 
300
+ /**
301
+ * Check current force cacheable bit set
302
+ *
303
+ * @access public
304
+ * @since 2.2
305
+ */
306
+ public static function is_forced_cacheable()
307
+ {
308
+ return self::$_control & self::BM_FORCED_CACHEABLE ;
309
+ }
310
+
311
  /**
312
  * Check current cacheable status
313
  *
317
  */
318
  public static function is_cacheable()
319
  {
320
+ // If its forced cacheable
321
+ if ( self::is_forced_cacheable() ) {
322
+ return true ;
323
+ }
324
+
325
  return ! self::isset_notcacheable() && self::$_control & self::BM_CACHEABLE ;
326
  }
327
 
 
 
 
328
  /**
329
  * Set a custom TTL to use with the request if needed.
330
  *
486
  */
487
  public static function finalize()
488
  {
489
+ // Check if URI is forced cache
490
+ $excludes = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_FORCE_CACHE_URI ) ;
491
+ if ( ! empty( $excludes ) ) {
492
+ $result = LiteSpeed_Cache_Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], explode( "\n", $excludes ) ) ;
493
+ if ( $result ) {
494
+ self::force_cacheable() ;
495
+ LiteSpeed_Cache_Log::debug( '[Ctrl] Forced cacheable due to setting: ' . $result ) ;
496
+ }
497
+ }
498
+
499
  // if is not cacheable, terminate check
500
  // Even no need to run 3rd party hook
501
  if ( ! self::is_cacheable() ) {
555
  return ;
556
  }
557
 
558
+ if ( isset($_SERVER['LSCACHE_VARY_VALUE']) && strpos( $_SERVER['LSCACHE_VARY_VALUE'], 'ismobile' ) !== false ) {
559
  if ( ! wp_is_mobile() && ! self::is_mobile() ) {
560
  self::set_nocache( 'is not mobile' ) ;
561
  return ;
610
  // Check private cache URI setting
611
  $excludes = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_URI_PRIV ) ;
612
  if ( ! empty( $excludes ) ) {
613
+ $result = LiteSpeed_Cache_Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], explode( "\n", $excludes ) ) ;
 
614
  if ( $result ) {
615
  self::set_private( 'Admin cfg Private Cached URI: ' . $result ) ;
616
  }
617
  }
618
 
619
+ if ( ! self::is_forced_cacheable() ) {
620
+
621
+ // Check if URI is excluded from cache
622
+ $excludes = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_EXCLUDES_URI ) ;
623
+ if ( ! empty( $excludes ) ) {
624
+ $result = LiteSpeed_Cache_Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], explode( "\n", $excludes ) ) ;
625
+ if ( $result ) {
626
+ return $this->_no_cache_for( 'Admin configured URI Do not cache: ' . $result ) ;
627
+ }
628
  }
 
629
 
630
+ // Check QS excluded setting
631
+ $excludes = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_EXCLUDES_QS ) ;
632
+ if ( ! empty( $excludes ) && $qs = $this->_is_qs_excluded( explode( "\n", $excludes ) ) ) {
633
+ return $this->_no_cache_for( 'Admin configured QS Do not cache: ' . $qs ) ;
634
+ }
635
 
636
+ $excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::OPID_EXCLUDES_CAT) ;
637
+ if ( ! empty($excludes) && has_category(explode(',', $excludes)) ) {
638
+ return $this->_no_cache_for('Admin configured Category Do not cache.') ;
639
+ }
640
 
641
+ $excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::OPID_EXCLUDES_TAG) ;
642
+ if ( ! empty($excludes) && has_tag(explode(',', $excludes)) ) {
643
+ return $this->_no_cache_for('Admin configured Tag Do not cache.') ;
644
+ }
645
 
646
+ $excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::ID_NOCACHE_COOKIES) ;
647
+ if ( ! empty($excludes) && ! empty($_COOKIE) ) {
648
+ $exclude_list = explode('|', $excludes) ;
649
 
650
+ foreach( $_COOKIE as $key=>$val) {
651
+ if ( in_array($key, $exclude_list) ) {
652
+ return $this->_no_cache_for('Admin configured Cookie Do not cache.') ;
653
+ }
654
  }
655
  }
 
656
 
657
+ $excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::ID_NOCACHE_USERAGENTS) ;
658
+ if ( ! empty($excludes) && isset($_SERVER['HTTP_USER_AGENT']) ) {
659
+ $pattern = '/' . $excludes . '/' ;
660
+ $nummatches = preg_match($pattern, $_SERVER['HTTP_USER_AGENT']) ;
661
+ if ( $nummatches ) {
662
+ return $this->_no_cache_for('Admin configured User Agent Do not cache.') ;
663
+ }
664
  }
 
665
 
666
+ // Check if is exclude roles ( Need to set Vary too )
667
+ if ( $result = LiteSpeed_Cache_Config::get_instance()->in_exclude_cache_roles() ) {
668
+ return $this->_no_cache_for( 'Role Excludes setting ' . $result ) ;
669
+ }
670
  }
671
 
 
 
672
  return true ;
673
  }
674
 
includes/litespeed-cache-gui.class.php CHANGED
@@ -275,7 +275,7 @@ class LiteSpeed_Cache_GUI
275
  'parent' => 'litespeed-menu',
276
  'id' => 'litespeed-purge-single',
277
  'title' => __( 'Purge this page', 'litespeed-cache' ),
278
- 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_FRONT_PURGE, false, false, true ),
279
  'meta' => array( 'tabindex' => '0' ),
280
  ) );
281
 
@@ -286,6 +286,13 @@ class LiteSpeed_Cache_GUI
286
  'meta' => array( 'tabindex' => '0' ),
287
  ) );
288
 
 
 
 
 
 
 
 
289
  $wp_admin_bar->add_menu( array(
290
  'parent' => 'litespeed-single-action',
291
  'id' => 'litespeed-single-noncache',
@@ -331,7 +338,7 @@ class LiteSpeed_Cache_GUI
331
  $wp_admin_bar->add_menu( array(
332
  'id' => 'litespeed-menu',
333
  'title' => '<span class="ab-icon" title="' . __( 'LiteSpeed Cache Purge All', 'litespeed-cache' ) . '""></span>',
334
- 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_PURGE_ALL ),
335
  'meta' => array( 'tabindex' => 0, 'class' => 'litespeed-top-toolbar' ),
336
  ) ) ;
337
  }
@@ -372,16 +379,24 @@ class LiteSpeed_Cache_GUI
372
  $wp_admin_bar->add_menu( array(
373
  'parent' => 'litespeed-menu',
374
  'id' => 'litespeed-purge-all',
375
- 'title' => __( 'LSCache Purge All', 'litespeed-cache' ),
376
- 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_PURGE_ALL ),
 
 
 
 
 
 
 
 
377
  'meta' => array( 'tabindex' => '0' ),
378
  ) );
379
 
380
  $wp_admin_bar->add_menu( array(
381
  'parent' => 'litespeed-menu',
382
  'id' => 'litespeed-purge-cssjs',
383
- 'title' => __( 'Purge CSS/JS Cache', 'litespeed-cache' ),
384
- 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_PURGE_CSSJS ),
385
  'meta' => array( 'tabindex' => '0' ),
386
  ) );
387
 
@@ -389,7 +404,7 @@ class LiteSpeed_Cache_GUI
389
  $wp_admin_bar->add_menu( array(
390
  'parent' => 'litespeed-menu',
391
  'id' => 'litespeed-purge-cloudflare',
392
- 'title' => __( 'Cloudflare Purge All', 'litespeed-cache' ),
393
  'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_CDN_CLOUDFLARE, LiteSpeed_Cache_CDN_Cloudflare::TYPE_PURGE_ALL ),
394
  'meta' => array( 'tabindex' => '0' ),
395
  ) );
@@ -399,8 +414,8 @@ class LiteSpeed_Cache_GUI
399
  $wp_admin_bar->add_menu( array(
400
  'parent' => 'litespeed-menu',
401
  'id' => 'litespeed-purge-object',
402
- 'title' => __( 'Object Cache Purge All', 'litespeed-cache' ),
403
- 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_PURGE, LiteSpeed_Cache_Purge::TYPE_OBJECT_PURGE_ALL ),
404
  'meta' => array( 'tabindex' => '0' ),
405
  ) );
406
  }
@@ -409,8 +424,8 @@ class LiteSpeed_Cache_GUI
409
  $wp_admin_bar->add_menu( array(
410
  'parent' => 'litespeed-menu',
411
  'id' => 'litespeed-purge-opcache',
412
- 'title' => __( 'Opcode Cache Purge All', 'litespeed-cache' ),
413
- 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_PURGE, LiteSpeed_Cache_Purge::TYPE_OPCACHE_PURGE_ALL ),
414
  'meta' => array( 'tabindex' => '0' ),
415
  ) );
416
  }
275
  'parent' => 'litespeed-menu',
276
  'id' => 'litespeed-purge-single',
277
  'title' => __( 'Purge this page', 'litespeed-cache' ),
278
+ 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_PURGE, LiteSpeed_Cache_Purge::TYPE_PURGE_FRONT, false, true ),
279
  'meta' => array( 'tabindex' => '0' ),
280
  ) );
281
 
286
  'meta' => array( 'tabindex' => '0' ),
287
  ) );
288
 
289
+ $wp_admin_bar->add_menu( array(
290
+ 'parent' => 'litespeed-single-action',
291
+ 'id' => 'litespeed-single-forced_cache',
292
+ 'title' => __( 'Forced cacheable', 'litespeed-cache' ),
293
+ 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_FRONT_EXCLUDE, 'forced_cache', false, true ),
294
+ ) );
295
+
296
  $wp_admin_bar->add_menu( array(
297
  'parent' => 'litespeed-single-action',
298
  'id' => 'litespeed-single-noncache',
338
  $wp_admin_bar->add_menu( array(
339
  'id' => 'litespeed-menu',
340
  'title' => '<span class="ab-icon" title="' . __( 'LiteSpeed Cache Purge All', 'litespeed-cache' ) . '""></span>',
341
+ 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_PURGE, LiteSpeed_Cache_Purge::TYPE_PURGE_ALL ),
342
  'meta' => array( 'tabindex' => 0, 'class' => 'litespeed-top-toolbar' ),
343
  ) ) ;
344
  }
379
  $wp_admin_bar->add_menu( array(
380
  'parent' => 'litespeed-menu',
381
  'id' => 'litespeed-purge-all',
382
+ 'title' => __( 'Purge All', 'litespeed-cache' ),
383
+ 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_PURGE, LiteSpeed_Cache_Purge::TYPE_PURGE_ALL ),
384
+ 'meta' => array( 'tabindex' => '0' ),
385
+ ) );
386
+
387
+ $wp_admin_bar->add_menu( array(
388
+ 'parent' => 'litespeed-menu',
389
+ 'id' => 'litespeed-lscache-purge-all',
390
+ 'title' => __( 'Purge All', 'litespeed-cache' ) . ' - ' . __( 'LSCache', 'litespeed-cache' ),
391
+ 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_PURGE, LiteSpeed_Cache_Purge::TYPE_PURGE_ALL_LSCACHE ),
392
  'meta' => array( 'tabindex' => '0' ),
393
  ) );
394
 
395
  $wp_admin_bar->add_menu( array(
396
  'parent' => 'litespeed-menu',
397
  'id' => 'litespeed-purge-cssjs',
398
+ 'title' => __( 'Purge All', 'litespeed-cache' ) . ' - ' . __( 'CSS/JS Cache', 'litespeed-cache' ),
399
+ 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_PURGE, LiteSpeed_Cache_Purge::TYPE_PURGE_ALL_CSSJS ),
400
  'meta' => array( 'tabindex' => '0' ),
401
  ) );
402
 
404
  $wp_admin_bar->add_menu( array(
405
  'parent' => 'litespeed-menu',
406
  'id' => 'litespeed-purge-cloudflare',
407
+ 'title' => __( 'Purge All', 'litespeed-cache' ) . ' - ' . __( 'Cloudflare', 'litespeed-cache' ),
408
  'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_CDN_CLOUDFLARE, LiteSpeed_Cache_CDN_Cloudflare::TYPE_PURGE_ALL ),
409
  'meta' => array( 'tabindex' => '0' ),
410
  ) );
414
  $wp_admin_bar->add_menu( array(
415
  'parent' => 'litespeed-menu',
416
  'id' => 'litespeed-purge-object',
417
+ 'title' => __( 'Purge All', 'litespeed-cache' ) . ' - ' . __( 'Object Cache', 'litespeed-cache' ),
418
+ 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_PURGE, LiteSpeed_Cache_Purge::TYPE_PURGE_ALL_OBJECT ),
419
  'meta' => array( 'tabindex' => '0' ),
420
  ) );
421
  }
424
  $wp_admin_bar->add_menu( array(
425
  'parent' => 'litespeed-menu',
426
  'id' => 'litespeed-purge-opcache',
427
+ 'title' => __( 'Purge All', 'litespeed-cache' ) . ' - ' . __( 'Opcode Cache', 'litespeed-cache' ),
428
+ 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_PURGE, LiteSpeed_Cache_Purge::TYPE_PURGE_ALL_OPCACHE ),
429
  'meta' => array( 'tabindex' => '0' ),
430
  ) );
431
  }
includes/litespeed-cache-optimize.class.php CHANGED
@@ -367,7 +367,7 @@ class LiteSpeed_Cache_Optimize
367
  // Check if hit URI excludes
368
  $excludes = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_EXCLUDES ) ;
369
  if ( ! empty( $excludes ) ) {
370
- $result = LiteSpeed_Cache_Utility::str_hit_array( esc_url( $_SERVER[ 'REQUEST_URI' ] ), explode( "\n", $excludes ) ) ;
371
  if ( $result ) {
372
  LiteSpeed_Cache_Log::debug( '[Optm] bypass: hit URI Excludes setting: ' . $result ) ;
373
  return $content ;
367
  // Check if hit URI excludes
368
  $excludes = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_EXCLUDES ) ;
369
  if ( ! empty( $excludes ) ) {
370
+ $result = LiteSpeed_Cache_Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], explode( "\n", $excludes ) ) ;
371
  if ( $result ) {
372
  LiteSpeed_Cache_Log::debug( '[Optm] bypass: hit URI Excludes setting: ' . $result ) ;
373
  return $content ;
includes/litespeed-cache-purge.class.php CHANGED
@@ -4,6 +4,7 @@
4
  *
5
  * @since 1.1.3
6
  * @since 1.5 Moved into /inc
 
7
  * @package LiteSpeed_Cache
8
  * @subpackage LiteSpeed_Cache/inc
9
  * @author LiteSpeed Technologies <info@litespeedtech.com>
@@ -11,16 +12,24 @@
11
  class LiteSpeed_Cache_Purge
12
  {
13
  private static $_instance ;
14
- protected static $_pub_purge = array() ;
15
- protected static $_priv_purge = array() ;
16
- protected static $_purge_related = false ;
17
- protected static $_purge_single = false ;
18
 
19
  const X_HEADER = 'X-LiteSpeed-Purge' ;
20
  const PURGE_QUEUE = 'litespeed-cache-purge-queue' ;
21
 
22
- const TYPE_OBJECT_PURGE_ALL = 'object_purge_all' ;
23
- const TYPE_OPCACHE_PURGE_ALL = 'opcache_purge_all' ;
 
 
 
 
 
 
 
 
24
 
25
  /**
26
  * Handle all request actions from main cls
@@ -35,12 +44,40 @@ class LiteSpeed_Cache_Purge
35
  $type = LiteSpeed_Cache_Router::verify_type() ;
36
 
37
  switch ( $type ) {
38
- case self::TYPE_OBJECT_PURGE_ALL :
39
- $instance->_object_purge_all() ;
 
 
 
 
 
 
 
 
40
  break ;
41
 
42
- case self::TYPE_OPCACHE_PURGE_ALL :
43
- $instance->_opcache_purge_all() ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  break ;
45
 
46
  default:
@@ -50,29 +87,106 @@ class LiteSpeed_Cache_Purge
50
  LiteSpeed_Cache_Admin::redirect() ;
51
  }
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  /**
54
  * Purge opcode cache
55
  *
56
  * @since 1.8.2
57
  * @access private
58
  */
59
- private function _opcache_purge_all()
60
  {
61
  if ( ! LiteSpeed_Cache_Router::opcache_enabled() ) {
62
- LiteSpeed_Cache_Log::debug( 'Purge: Failed to reset opcode cache due to opcache not enabled' ) ;
63
 
64
- $msg = __( 'Opcode cache is not enabled.', 'litespeed-cache' ) ;
65
- LiteSpeed_Cache_Admin_Display::error( $msg ) ;
 
 
66
 
67
  return false ;
68
  }
69
 
70
  // Purge opcode cache
71
  opcache_reset() ;
72
- LiteSpeed_Cache_Log::debug( 'Purge: Reset opcode cache' ) ;
73
 
74
- $msg = __( 'Reset the entire opcode cache successfully.', 'litespeed-cache' ) ;
75
- LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
 
 
76
 
77
  return true ;
78
  }
@@ -83,21 +197,25 @@ class LiteSpeed_Cache_Purge
83
  * @since 1.8
84
  * @access private
85
  */
86
- private function _object_purge_all()
87
  {
88
  if ( ! defined( 'LSCWP_OBJECT_CACHE' ) ) {
89
- LiteSpeed_Cache_Log::debug( 'Purge: Failed to flush object cache due to object cache not enabled' ) ;
90
 
91
- $msg = __( 'Object cache is not enabled.', 'litespeed-cache' ) ;
92
- LiteSpeed_Cache_Admin_Display::error( $msg ) ;
 
 
93
 
94
  return false ;
95
  }
96
  LiteSpeed_Cache_Object::get_instance()->flush() ;
97
- LiteSpeed_Cache_Log::debug( 'Purge: Flushed object cache' ) ;
98
 
99
- $msg = __( 'Purge all object caches successfully.', 'litespeed-cache' ) ;
100
- LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
 
 
101
 
102
  return true ;
103
  }
@@ -110,28 +228,40 @@ class LiteSpeed_Cache_Purge
110
  * @param mixed $tags Tags to add to the list.
111
  */
112
  public static function add( $tags )
 
 
 
 
 
 
 
 
 
 
 
113
  {
114
  if ( ! is_array( $tags ) ) {
115
  $tags = array( $tags ) ;
116
  }
117
- if ( ! array_diff( $tags, self::$_pub_purge ) ) {
118
  return ;
119
  }
120
 
121
- self::$_pub_purge = array_merge( self::$_pub_purge, $tags ) ;
122
- LiteSpeed_Cache_Log::debug( 'Purge: added ' . implode( ',', $tags ), 3 ) ;
123
 
124
  // Send purge header immediately
125
- $curr_built = self::_build() ;
126
  if ( defined( 'LITESPEED_DID_send_headers' ) ) {
127
  // Can't send, already has output, need to save and wait for next run
128
  update_option( self::PURGE_QUEUE, $curr_built ) ;
129
- LiteSpeed_Cache_Log::debug( 'Output existed, Purge queue stored: ' . $curr_built ) ;
130
  }
131
  else {
132
  @header( $curr_built ) ;
133
  LiteSpeed_Cache_Log::debug( $curr_built ) ;
134
  }
 
135
  }
136
 
137
  /**
@@ -142,20 +272,31 @@ class LiteSpeed_Cache_Purge
142
  * @param mixed $tags Tags to add to the list.
143
  */
144
  public static function add_private( $tags )
 
 
 
 
 
 
 
 
 
 
 
145
  {
146
  if ( ! is_array( $tags ) ) {
147
  $tags = array( $tags ) ;
148
  }
149
- if ( ! array_diff( $tags, self::$_priv_purge ) ) {
150
  return ;
151
  }
152
 
153
- LiteSpeed_Cache_Log::debug( 'Purge: added [private] ' . implode( ',', $tags ), 3 ) ;
154
 
155
- self::$_priv_purge = array_merge( self::$_priv_purge, $tags ) ;
156
 
157
  // Send purge header immediately
158
- @header( self::_build() ) ;
159
  }
160
 
161
  /**
@@ -166,7 +307,7 @@ class LiteSpeed_Cache_Purge
166
  */
167
  public static function set_purge_related()
168
  {
169
- self::$_purge_related = true ;
170
  }
171
 
172
  /**
@@ -177,94 +318,89 @@ class LiteSpeed_Cache_Purge
177
  */
178
  public static function set_purge_single()
179
  {
180
- self::$_purge_single = true ;
181
  }
182
 
183
  /**
184
- * Check qs purge status
185
  *
186
- * @since 1.1.3
187
  * @access public
188
  */
189
- public static function get_qs_purge()
190
  {
191
- return self::$_purge_single || self::$_purge_related ;
192
  }
193
 
194
  /**
195
- * Alerts LiteSpeed Web Server to purge all pages.
196
- *
197
- * For multisite installs, if this is called by a site admin (not network admin),
198
- * it will only purge all posts associated with that site.
199
  *
200
- * @since 1.0.0
201
- * @access public
 
202
  */
203
- public static function purge_all()
204
  {
205
- self::add( '*' ) ;
206
-
207
- // check if need to reset crawler
208
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE ) ) {
209
- LiteSpeed_Cache_Crawler::get_instance()->reset_pos() ;
210
  }
 
 
 
 
 
211
  }
212
 
213
  /**
214
  * Alerts LiteSpeed Web Server to purge the front page.
215
  *
216
  * @since 1.0.3
217
- * @access public
 
218
  */
219
- public static function purge_front()
220
  {
221
- self::add( LiteSpeed_Cache_Tag::TYPE_FRONTPAGE ) ;
222
  if ( LITESPEED_SERVER_TYPE !== 'LITESPEED_SERVER_OLS' ) {
223
- self::add_private( LiteSpeed_Cache_Tag::TYPE_FRONTPAGE ) ;
224
  }
225
- }
226
 
227
- /**
228
- * Alerts LiteSpeed Web Server to purge pages.
229
- *
230
- * @since 1.0.15
231
- * @access public
232
- */
233
- public static function purge_pages()
234
- {
235
- self::add( LiteSpeed_Cache_Tag::TYPE_PAGES ) ;
236
  }
237
 
238
  /**
239
  * Alerts LiteSpeed Web Server to purge pages.
240
  *
241
- * @since 1.2.2
242
- * @access public
243
  */
244
- public static function purge_cssjs()
245
  {
246
- self::add( LiteSpeed_Cache_Tag::TYPE_MIN ) ;
247
 
248
- // For non-ls users
249
- LiteSpeed_Cache_Optimize::get_instance()->rm_cache_folder() ;
250
  }
251
 
252
  /**
253
  * Alerts LiteSpeed Web Server to purge error pages.
254
  *
255
  * @since 1.0.14
256
- * @access public
257
  */
258
- public static function purge_errors()
259
  {
260
- self::add( LiteSpeed_Cache_Tag::TYPE_ERROR ) ;
261
 
262
- $type = LiteSpeed_Cache_Router::verify_type() ;
263
  if ( ! $type || ! in_array( $type, array( '403', '404', '500' ) ) ) {
264
  return ;
265
  }
266
 
267
- self::add( LiteSpeed_Cache_Tag::TYPE_ERROR . $type ) ;
 
 
 
268
  }
269
 
270
  /**
@@ -291,9 +427,9 @@ class LiteSpeed_Cache_Purge
291
  return ;
292
  }
293
 
294
- LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, sprintf( __( 'Purge category %s', 'litespeed-cache' ), $val ) ) ;
295
 
296
- self::add( LiteSpeed_Cache_Tag::TYPE_ARCHIVE_TERM . $cat->term_id ) ;
297
  }
298
 
299
  /**
@@ -318,9 +454,9 @@ class LiteSpeed_Cache_Purge
318
  LiteSpeed_Cache_Admin_Display::add_error( LiteSpeed_Cache_Admin_Error::E_PURGEBY_PID_DNE, $val ) ;
319
  return ;
320
  }
321
- LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, sprintf( __( 'Purge Post ID %s', 'litespeed-cache' ), $val ) ) ;
322
 
323
- self::add( LiteSpeed_Cache_Tag::TYPE_POST . $val ) ;
324
  }
325
 
326
  /**
@@ -347,9 +483,9 @@ class LiteSpeed_Cache_Purge
347
  return ;
348
  }
349
 
350
- LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, sprintf( __( 'Purge tag %s', 'litespeed-cache' ), $val ) ) ;
351
 
352
- self::add( LiteSpeed_Cache_Tag::TYPE_ARCHIVE_TERM . $term->term_id ) ;
353
  }
354
 
355
  /**
@@ -381,9 +517,9 @@ class LiteSpeed_Cache_Purge
381
  return ;
382
  }
383
 
384
- LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, sprintf( __( 'Purge url %s', 'litespeed-cache' ), $val ) ) ;
385
 
386
- self::add( $hash ) ;
387
  return ;
388
  }
389
 
@@ -425,29 +561,10 @@ class LiteSpeed_Cache_Purge
425
  LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_PURGEBY_BAD) ;
426
  return ;
427
  }
428
- array_walk($list, Array($this, $cb)) ;
429
 
430
  // for redirection
431
- $_GET[LiteSpeed_Cache_Admin_Display::PURGEBYOPT_SELECT] = $sel ;
432
- }
433
-
434
- /**
435
- * Purge frontend url
436
- *
437
- * @since 1.3
438
- * @access public
439
- */
440
- public static function frontend_purge()
441
- {
442
- if ( empty( $_SERVER[ 'HTTP_REFERER' ] ) ) {
443
- exit( 'no referer' ) ;
444
- }
445
- $instance = self::get_instance() ;
446
-
447
- $instance->purgeby_url_cb( $_SERVER[ 'HTTP_REFERER' ] ) ;
448
-
449
- wp_redirect( $_SERVER[ 'HTTP_REFERER' ] ) ;
450
- exit() ;
451
  }
452
 
453
  /**
@@ -468,17 +585,19 @@ class LiteSpeed_Cache_Purge
468
  return ;
469
  }
470
 
471
- $purge_tags = self::get_purge_tags_by_post($post_id) ;
 
 
472
  if ( empty($purge_tags) ) {
473
  return ;
474
  }
475
  if ( in_array( '*', $purge_tags ) ) {
476
- self::purge_all() ;
477
  }
478
  else {
479
- self::add( $purge_tags ) ;
480
  if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_REST ) ) {
481
- self::add( LiteSpeed_Cache_Tag::TYPE_REST ) ;
482
  }
483
  }
484
  LiteSpeed_Cache_Control::set_stale() ;
@@ -553,7 +672,7 @@ class LiteSpeed_Cache_Purge
553
  * @access private
554
  * @since 1.1.3
555
  */
556
- private static function _finalize()
557
  {
558
  // Make sure header output only run once
559
  if ( ! defined( 'LITESPEED_DID_' . __FUNCTION__ ) ) {
@@ -566,26 +685,26 @@ class LiteSpeed_Cache_Purge
566
  do_action('litespeed_cache_api_purge') ;
567
 
568
  // Append unique uri purge tags if Admin QS is `PURGESINGLE`
569
- if ( self::$_purge_single ) {
570
- self::$_pub_purge[] = LiteSpeed_Cache_Tag::build_uri_tag() ; // TODO: add private tag too
571
  }
572
  // Append related purge tags if Admin QS is `PURGE`
573
- if ( self::$_purge_related ) {
574
  // Before this, tags need to be finalized
575
  $tags_related = LiteSpeed_Cache_Tag::output_tags() ;
576
  // NOTE: need to remove the empty item `B1_` to avoid purging all
577
  $tags_related = array_filter($tags_related) ;
578
  if ( $tags_related ) {
579
- self::$_pub_purge = array_merge(self::$_pub_purge, $tags_related) ;
580
  }
581
  }
582
 
583
- if ( ! empty(self::$_pub_purge) ) {
584
- self::$_pub_purge = array_unique(self::$_pub_purge) ;
585
  }
586
 
587
- if ( ! empty(self::$_priv_purge) ) {
588
- self::$_priv_purge = array_unique(self::$_priv_purge) ;
589
  }
590
  }
591
 
@@ -600,9 +719,11 @@ class LiteSpeed_Cache_Purge
600
  */
601
  public static function output()
602
  {
603
- self::_finalize() ;
 
 
604
 
605
- return self::_build() ;
606
  }
607
 
608
  /**
@@ -612,17 +733,17 @@ class LiteSpeed_Cache_Purge
612
  * @access private
613
  * @return string the built purge header
614
  */
615
- private static function _build()
616
  {
617
- if ( empty( self::$_pub_purge ) && empty( self::$_priv_purge ) ) {
618
  return ;
619
  }
620
 
621
  $purge_header = '' ;
622
  $private_prefix = self::X_HEADER . ': private,' ;
623
 
624
- if ( ! empty( self::$_pub_purge ) ) {
625
- $public_tags = self::_append_prefix( self::$_pub_purge ) ;
626
  if ( empty( $public_tags ) ) {
627
  // If this ends up empty, private will also end up empty
628
  return ;
@@ -636,8 +757,8 @@ class LiteSpeed_Cache_Purge
636
  }
637
 
638
  // Handle priv purge tags
639
- if ( ! empty( self::$_priv_purge ) ) {
640
- $private_tags = self::_append_prefix( self::$_priv_purge, true ) ;
641
  $purge_header .= $private_prefix . implode( ',', $private_tags ) ;
642
  }
643
 
@@ -653,7 +774,7 @@ class LiteSpeed_Cache_Purge
653
  * @param boolean $is_private If is private tags or not.
654
  * @return array The array of built purge tags.
655
  */
656
- private static function _append_prefix( $purge_tags, $is_private = false )
657
  {
658
  $curr_bid = get_current_blog_id() ;
659
 
@@ -676,7 +797,7 @@ class LiteSpeed_Cache_Purge
676
  )) ) {
677
  $blogs = LiteSpeed_Cache_Activation::get_network_ids() ;
678
  if ( empty($blogs) ) {
679
- LiteSpeed_Cache_Log::debug('build_purge_headers: blog list is empty') ;
680
  return '' ;
681
  }
682
  $tags = array() ;
@@ -699,11 +820,11 @@ class LiteSpeed_Cache_Purge
699
  * any third party plugin specific post tags.
700
  *
701
  * @since 1.0.0
702
- * @access public
703
  * @param integer $post_id The id of the post about to be purged.
704
  * @return array The list of purge tags correlated with the post.
705
  */
706
- public static function get_purge_tags_by_post( $post_id )
707
  {
708
  // If this is a valid post we want to purge the post, the home page and any associated tags & cats
709
  // If not, purge everything on the site.
@@ -836,7 +957,7 @@ class LiteSpeed_Cache_Purge
836
  */
837
  public static function get_instance()
838
  {
839
- if ( ! isset(self::$_instance) ) {
840
  self::$_instance = new self() ;
841
  }
842
 
4
  *
5
  * @since 1.1.3
6
  * @since 1.5 Moved into /inc
7
+ * @since 2.2 Refactored. Changed access from public to private for most func and class variables.
8
  * @package LiteSpeed_Cache
9
  * @subpackage LiteSpeed_Cache/inc
10
  * @author LiteSpeed Technologies <info@litespeedtech.com>
12
  class LiteSpeed_Cache_Purge
13
  {
14
  private static $_instance ;
15
+ protected $_pub_purge = array() ;
16
+ protected $_priv_purge = array() ;
17
+ protected $_purge_related = false ;
18
+ protected $_purge_single = false ;
19
 
20
  const X_HEADER = 'X-LiteSpeed-Purge' ;
21
  const PURGE_QUEUE = 'litespeed-cache-purge-queue' ;
22
 
23
+ const TYPE_PURGE_ALL = 'purge_all' ;
24
+ const TYPE_PURGE_ALL_LSCACHE = 'purge_all_lscache' ;
25
+ const TYPE_PURGE_ALL_CSSJS = 'purge_all_cssjs' ;
26
+ const TYPE_PURGE_ALL_OBJECT = 'purge_all_object' ;
27
+ const TYPE_PURGE_ALL_OPCACHE = 'purge_all_opcache' ;
28
+
29
+ const TYPE_PURGE_FRONT = 'purge_front' ;
30
+ const TYPE_PURGE_FRONTPAGE = 'purge_frontpage' ;
31
+ const TYPE_PURGE_PAGES = 'purge_pages' ;
32
+ const TYPE_PURGE_ERROR = 'purge_error' ;
33
 
34
  /**
35
  * Handle all request actions from main cls
44
  $type = LiteSpeed_Cache_Router::verify_type() ;
45
 
46
  switch ( $type ) {
47
+ case self::TYPE_PURGE_ALL :
48
+ $instance->_purge_all() ;
49
+ break ;
50
+
51
+ case self::TYPE_PURGE_ALL_LSCACHE :
52
+ $instance->_purge_all_lscache() ;
53
+ break ;
54
+
55
+ case self::TYPE_PURGE_ALL_CSSJS :
56
+ $instance->_purge_all_cssjs() ;
57
  break ;
58
 
59
+ case self::TYPE_PURGE_ALL_OBJECT :
60
+ $instance->_purge_all_object() ;
61
+ break ;
62
+
63
+ case self::TYPE_PURGE_ALL_OPCACHE :
64
+ $instance->_purge_all_opcache() ;
65
+ break ;
66
+
67
+ case self::TYPE_PURGE_FRONT :
68
+ $instance->_purge_front() ;
69
+ break ;
70
+
71
+ case self::TYPE_PURGE_FRONTPAGE :
72
+ $instance->_purge_frontpage() ;
73
+ break ;
74
+
75
+ case self::TYPE_PURGE_PAGES :
76
+ $instance->_purge_pages() ;
77
+ break ;
78
+
79
+ case strpos( $type, self::TYPE_PURGE_ERROR ) === 0 :
80
+ $instance->_purge_error( substr( $type, strlen( self::TYPE_PURGE_ERROR ) ) ) ;
81
  break ;
82
 
83
  default:
87
  LiteSpeed_Cache_Admin::redirect() ;
88
  }
89
 
90
+ /**
91
+ * Shortcut to purge all lscache
92
+ *
93
+ * @since 1.0.0
94
+ * @access public
95
+ */
96
+ public static function purge_all( $reason = false )
97
+ {
98
+ self::get_instance()->_purge_all( $reason ) ;
99
+ }
100
+
101
+ /**
102
+ * Purge all caches (lscache/op/oc)
103
+ *
104
+ * @since 2.2
105
+ * @access private
106
+ */
107
+ private function _purge_all( $reason = false )
108
+ {
109
+ $this->_purge_all_lscache( true ) ;
110
+ $this->_purge_all_cssjs( true ) ;
111
+ $this->_purge_all_object( true ) ;
112
+ $this->_purge_all_opcache( true ) ;
113
+
114
+ LiteSpeed_Cache_Log::debug( '[Purge] Purge all' . ( $reason ? ' [Reason] ' . $reason : '' ), 3 ) ;
115
+
116
+ $msg = __( 'Purge all caches successfully.', 'litespeed-cache' ) ;
117
+ LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
118
+ }
119
+
120
+ /**
121
+ * Alerts LiteSpeed Web Server to purge all pages.
122
+ *
123
+ * For multisite installs, if this is called by a site admin (not network admin),
124
+ * it will only purge all posts associated with that site.
125
+ *
126
+ * @since 2.2
127
+ * @access public
128
+ */
129
+ private function _purge_all_lscache( $silence = false )
130
+ {
131
+ $this->_add( '*' ) ;
132
+
133
+ // check if need to reset crawler
134
+ if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE ) ) {
135
+ LiteSpeed_Cache_Crawler::get_instance()->reset_pos() ;
136
+ }
137
+
138
+ if ( ! $silence ) {
139
+ $msg = __( 'Notified LiteSpeed Web Server to purge all LSCache entries.', 'litespeed-cache' ) ;
140
+ LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
141
+ }
142
+ }
143
+
144
+ /**
145
+ * Alerts LiteSpeed Web Server to purge pages.
146
+ *
147
+ * @since 1.2.2
148
+ * @access private
149
+ */
150
+ private function _purge_all_cssjs( $silence = false )
151
+ {
152
+ $this->_add( LiteSpeed_Cache_Tag::TYPE_MIN ) ;
153
+
154
+ // For non-ls users
155
+ LiteSpeed_Cache_Optimize::get_instance()->rm_cache_folder() ;
156
+
157
+ if ( ! $silence ) {
158
+ $msg = __( 'Notified LiteSpeed Web Server to purge CSS/JS entries.', 'litespeed-cache' ) ;
159
+ LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
160
+ }
161
+ }
162
+
163
  /**
164
  * Purge opcode cache
165
  *
166
  * @since 1.8.2
167
  * @access private
168
  */
169
+ private function _purge_all_opcache( $silence = false )
170
  {
171
  if ( ! LiteSpeed_Cache_Router::opcache_enabled() ) {
172
+ LiteSpeed_Cache_Log::debug( '[Purge] Failed to reset opcode cache due to opcache not enabled' ) ;
173
 
174
+ if ( ! $silence ) {
175
+ $msg = __( 'Opcode cache is not enabled.', 'litespeed-cache' ) ;
176
+ LiteSpeed_Cache_Admin_Display::error( $msg ) ;
177
+ }
178
 
179
  return false ;
180
  }
181
 
182
  // Purge opcode cache
183
  opcache_reset() ;
184
+ LiteSpeed_Cache_Log::debug( '[Purge] Reset opcode cache' ) ;
185
 
186
+ if ( ! $silence ) {
187
+ $msg = __( 'Reset the entire opcode cache successfully.', 'litespeed-cache' ) ;
188
+ LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
189
+ }
190
 
191
  return true ;
192
  }
197
  * @since 1.8
198
  * @access private
199
  */
200
+ private function _purge_all_object( $silence = false )
201
  {
202
  if ( ! defined( 'LSCWP_OBJECT_CACHE' ) ) {
203
+ LiteSpeed_Cache_Log::debug( '[Purge] Failed to flush object cache due to object cache not enabled' ) ;
204
 
205
+ if ( ! $silence ) {
206
+ $msg = __( 'Object cache is not enabled.', 'litespeed-cache' ) ;
207
+ LiteSpeed_Cache_Admin_Display::error( $msg ) ;
208
+ }
209
 
210
  return false ;
211
  }
212
  LiteSpeed_Cache_Object::get_instance()->flush() ;
213
+ LiteSpeed_Cache_Log::debug( '[Purge] Flushed object cache' ) ;
214
 
215
+ if ( ! $silence ) {
216
+ $msg = __( 'Purge all object caches successfully.', 'litespeed-cache' ) ;
217
+ LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
218
+ }
219
 
220
  return true ;
221
  }
228
  * @param mixed $tags Tags to add to the list.
229
  */
230
  public static function add( $tags )
231
+ {
232
+ self::get_instance()->_add( $tags ) ;
233
+ }
234
+
235
+ /**
236
+ * Add tags to purge
237
+ *
238
+ * @since 2.2
239
+ * @access private
240
+ */
241
+ private function _add( $tags )
242
  {
243
  if ( ! is_array( $tags ) ) {
244
  $tags = array( $tags ) ;
245
  }
246
+ if ( ! array_diff( $tags, $this->_pub_purge ) ) {
247
  return ;
248
  }
249
 
250
+ $this->_pub_purge = array_merge( $this->_pub_purge, $tags ) ;
251
+ LiteSpeed_Cache_Log::debug( '[Purge] added ' . implode( ',', $tags ), 3 ) ;
252
 
253
  // Send purge header immediately
254
+ $curr_built = $this->_build() ;
255
  if ( defined( 'LITESPEED_DID_send_headers' ) ) {
256
  // Can't send, already has output, need to save and wait for next run
257
  update_option( self::PURGE_QUEUE, $curr_built ) ;
258
+ LiteSpeed_Cache_Log::debug( '[Purge] Output existed, queue stored: ' . $curr_built ) ;
259
  }
260
  else {
261
  @header( $curr_built ) ;
262
  LiteSpeed_Cache_Log::debug( $curr_built ) ;
263
  }
264
+
265
  }
266
 
267
  /**
272
  * @param mixed $tags Tags to add to the list.
273
  */
274
  public static function add_private( $tags )
275
+ {
276
+ self::get_instance()->_add_private( $tags ) ;
277
+ }
278
+
279
+ /**
280
+ * Add tags to private purge
281
+ *
282
+ * @since 2.2
283
+ * @access private
284
+ */
285
+ private function _add_private( $tags )
286
  {
287
  if ( ! is_array( $tags ) ) {
288
  $tags = array( $tags ) ;
289
  }
290
+ if ( ! array_diff( $tags, $this->_priv_purge ) ) {
291
  return ;
292
  }
293
 
294
+ LiteSpeed_Cache_Log::debug( '[Purge] added [private] ' . implode( ',', $tags ), 3 ) ;
295
 
296
+ $this->_priv_purge = array_merge( $this->_priv_purge, $tags ) ;
297
 
298
  // Send purge header immediately
299
+ @header( $this->_build() ) ;
300
  }
301
 
302
  /**
307
  */
308
  public static function set_purge_related()
309
  {
310
+ self::get_instance()->_purge_related = true ;
311
  }
312
 
313
  /**
318
  */
319
  public static function set_purge_single()
320
  {
321
+ self::get_instance()->_purge_single = true ;
322
  }
323
 
324
  /**
325
+ * Called from cfg::frontend_save() to purge front page
326
  *
327
+ * @since 2.2
328
  * @access public
329
  */
330
+ public static function purge_front()
331
  {
332
+ self::get_instance()->_purge_front() ;
333
  }
334
 
335
  /**
336
+ * Purge frontend url
 
 
 
337
  *
338
+ * @since 1.3
339
+ * @since 2.2 Renamed from `frontend_purge`; Access changed from public
340
+ * @access private
341
  */
342
+ private function _purge_front()
343
  {
344
+ if ( empty( $_SERVER[ 'HTTP_REFERER' ] ) ) {
345
+ exit( 'no referer' ) ;
 
 
 
346
  }
347
+
348
+ $this->purgeby_url_cb( $_SERVER[ 'HTTP_REFERER' ] ) ;
349
+
350
+ wp_redirect( $_SERVER[ 'HTTP_REFERER' ] ) ;
351
+ exit() ;
352
  }
353
 
354
  /**
355
  * Alerts LiteSpeed Web Server to purge the front page.
356
  *
357
  * @since 1.0.3
358
+ * @since 2.2 Access changed from public to private, renamed from `_purge_front`
359
+ * @access private
360
  */
361
+ private function _purge_frontpage()
362
  {
363
+ $this->_add( LiteSpeed_Cache_Tag::TYPE_FRONTPAGE ) ;
364
  if ( LITESPEED_SERVER_TYPE !== 'LITESPEED_SERVER_OLS' ) {
365
+ $this->_add_private( LiteSpeed_Cache_Tag::TYPE_FRONTPAGE ) ;
366
  }
 
367
 
368
+ $msg = __( 'Notified LiteSpeed Web Server to purge the front page.', 'litespeed-cache' ) ;
369
+ LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
 
 
 
 
 
 
 
370
  }
371
 
372
  /**
373
  * Alerts LiteSpeed Web Server to purge pages.
374
  *
375
+ * @since 1.0.15
376
+ * @access private
377
  */
378
+ private function _purge_pages()
379
  {
380
+ $this->_add( LiteSpeed_Cache_Tag::TYPE_PAGES ) ;
381
 
382
+ $msg = __( 'Notified LiteSpeed Web Server to purge pages.', 'litespeed-cache' ) ;
383
+ LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
384
  }
385
 
386
  /**
387
  * Alerts LiteSpeed Web Server to purge error pages.
388
  *
389
  * @since 1.0.14
390
+ * @access private
391
  */
392
+ private function _purge_error( $type = false )
393
  {
394
+ $this->_add( LiteSpeed_Cache_Tag::TYPE_ERROR ) ;
395
 
 
396
  if ( ! $type || ! in_array( $type, array( '403', '404', '500' ) ) ) {
397
  return ;
398
  }
399
 
400
+ $this->_add( LiteSpeed_Cache_Tag::TYPE_ERROR . $type ) ;
401
+
402
+ $msg = __( 'Notified LiteSpeed Web Server to purge error pages.', 'litespeed-cache' ) ;
403
+ LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
404
  }
405
 
406
  /**
427
  return ;
428
  }
429
 
430
+ LiteSpeed_Cache_Admin_Display::succeed( sprintf( __( 'Purge category %s', 'litespeed-cache' ), $val ) ) ;
431
 
432
+ $this->_add( LiteSpeed_Cache_Tag::TYPE_ARCHIVE_TERM . $cat->term_id ) ;
433
  }
434
 
435
  /**
454
  LiteSpeed_Cache_Admin_Display::add_error( LiteSpeed_Cache_Admin_Error::E_PURGEBY_PID_DNE, $val ) ;
455
  return ;
456
  }
457
+ LiteSpeed_Cache_Admin_Display::succeed( sprintf( __( 'Purge Post ID %s', 'litespeed-cache' ), $val ) ) ;
458
 
459
+ $this->_add( LiteSpeed_Cache_Tag::TYPE_POST . $val ) ;
460
  }
461
 
462
  /**
483
  return ;
484
  }
485
 
486
+ LiteSpeed_Cache_Admin_Display::succeed( sprintf( __( 'Purge tag %s', 'litespeed-cache' ), $val ) ) ;
487
 
488
+ $this->_add( LiteSpeed_Cache_Tag::TYPE_ARCHIVE_TERM . $term->term_id ) ;
489
  }
490
 
491
  /**
517
  return ;
518
  }
519
 
520
+ LiteSpeed_Cache_Admin_Display::succeed( sprintf( __( 'Purge url %s', 'litespeed-cache' ), $val ) ) ;
521
 
522
+ $this->_add( $hash ) ;
523
  return ;
524
  }
525
 
561
  LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_PURGEBY_BAD) ;
562
  return ;
563
  }
564
+ array_walk( $list, array( $this, $cb ) ) ;
565
 
566
  // for redirection
567
+ $_GET[ LiteSpeed_Cache_Admin_Display::PURGEBYOPT_SELECT ] = $sel ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
568
  }
569
 
570
  /**
585
  return ;
586
  }
587
 
588
+ $instance = self::get_instance() ;
589
+
590
+ $purge_tags = $instance->_get_purge_tags_by_post($post_id) ;
591
  if ( empty($purge_tags) ) {
592
  return ;
593
  }
594
  if ( in_array( '*', $purge_tags ) ) {
595
+ $instance->_purge_all_lscache() ;
596
  }
597
  else {
598
+ $instance->_add( $purge_tags ) ;
599
  if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_REST ) ) {
600
+ $instance->_add( LiteSpeed_Cache_Tag::TYPE_REST ) ;
601
  }
602
  }
603
  LiteSpeed_Cache_Control::set_stale() ;
672
  * @access private
673
  * @since 1.1.3
674
  */
675
+ private function _finalize()
676
  {
677
  // Make sure header output only run once
678
  if ( ! defined( 'LITESPEED_DID_' . __FUNCTION__ ) ) {
685
  do_action('litespeed_cache_api_purge') ;
686
 
687
  // Append unique uri purge tags if Admin QS is `PURGESINGLE`
688
+ if ( $this->_purge_single ) {
689
+ $this->_pub_purge[] = LiteSpeed_Cache_Tag::build_uri_tag() ; // TODO: add private tag too
690
  }
691
  // Append related purge tags if Admin QS is `PURGE`
692
+ if ( $this->_purge_related ) {
693
  // Before this, tags need to be finalized
694
  $tags_related = LiteSpeed_Cache_Tag::output_tags() ;
695
  // NOTE: need to remove the empty item `B1_` to avoid purging all
696
  $tags_related = array_filter($tags_related) ;
697
  if ( $tags_related ) {
698
+ $this->_pub_purge = array_merge($this->_pub_purge, $tags_related) ;
699
  }
700
  }
701
 
702
+ if ( ! empty($this->_pub_purge) ) {
703
+ $this->_pub_purge = array_unique($this->_pub_purge) ;
704
  }
705
 
706
+ if ( ! empty($this->_priv_purge) ) {
707
+ $this->_priv_purge = array_unique($this->_priv_purge) ;
708
  }
709
  }
710
 
719
  */
720
  public static function output()
721
  {
722
+ $instance = self::get_instance() ;
723
+
724
+ $instance->_finalize() ;
725
 
726
+ return $instance->_build() ;
727
  }
728
 
729
  /**
733
  * @access private
734
  * @return string the built purge header
735
  */
736
+ private function _build()
737
  {
738
+ if ( empty( $this->_pub_purge ) && empty( $this->_priv_purge ) ) {
739
  return ;
740
  }
741
 
742
  $purge_header = '' ;
743
  $private_prefix = self::X_HEADER . ': private,' ;
744
 
745
+ if ( ! empty( $this->_pub_purge ) ) {
746
+ $public_tags = $this->_append_prefix( $this->_pub_purge ) ;
747
  if ( empty( $public_tags ) ) {
748
  // If this ends up empty, private will also end up empty
749
  return ;
757
  }
758
 
759
  // Handle priv purge tags
760
+ if ( ! empty( $this->_priv_purge ) ) {
761
+ $private_tags = $this->_append_prefix( $this->_priv_purge, true ) ;
762
  $purge_header .= $private_prefix . implode( ',', $private_tags ) ;
763
  }
764
 
774
  * @param boolean $is_private If is private tags or not.
775
  * @return array The array of built purge tags.
776
  */
777
+ private function _append_prefix( $purge_tags, $is_private = false )
778
  {
779
  $curr_bid = get_current_blog_id() ;
780
 
797
  )) ) {
798
  $blogs = LiteSpeed_Cache_Activation::get_network_ids() ;
799
  if ( empty($blogs) ) {
800
+ LiteSpeed_Cache_Log::debug('[Purge] build_purge_headers: blog list is empty') ;
801
  return '' ;
802
  }
803
  $tags = array() ;
820
  * any third party plugin specific post tags.
821
  *
822
  * @since 1.0.0
823
+ * @access private
824
  * @param integer $post_id The id of the post about to be purged.
825
  * @return array The list of purge tags correlated with the post.
826
  */
827
+ private function _get_purge_tags_by_post( $post_id )
828
  {
829
  // If this is a valid post we want to purge the post, the home page and any associated tags & cats
830
  // If not, purge everything on the site.
957
  */
958
  public static function get_instance()
959
  {
960
+ if ( ! isset( self::$_instance ) ) {
961
  self::$_instance = new self() ;
962
  }
963
 
includes/litespeed-cache-router.class.php CHANGED
@@ -346,31 +346,20 @@ class LiteSpeed_Cache_Router
346
  }
347
  return ;
348
 
349
- case LiteSpeed_Cache::ACTION_PURGE_FRONT:
350
- case LiteSpeed_Cache::ACTION_PURGE_PAGES:
351
- case LiteSpeed_Cache::ACTION_PURGE_ERRORS:
352
- case LiteSpeed_Cache::ACTION_PURGE_ALL:
353
  case LiteSpeed_Cache::ACTION_PURGE_BY:
354
- case LiteSpeed_Cache::ACTION_FRONT_PURGE:
355
  case LiteSpeed_Cache::ACTION_FRONT_EXCLUDE:
356
  if ( defined( 'LITESPEED_ON' ) && ( $_can_network_option || $_can_option || self::is_ajax() ) ) {//here may need more security
357
  self::$_action = $action ;
358
  }
359
  return ;
360
 
361
- case LiteSpeed_Cache::ACTION_PURGE_CSSJS: // will clear non-ls users file-based cache folder too
362
- if ( $_can_network_option || $_can_option || self::is_ajax() ) {
363
- self::$_action = $action ;
364
- }
365
- return ;
366
-
367
  case LiteSpeed_Cache::ACTION_DB_OPTIMIZE:
368
  if ( $_can_network_option || $_can_option ) {
369
  self::$_action = $action ;
370
  }
371
  return ;
372
 
373
- case LiteSpeed_Cache::ACTION_PURGE_EMPTYCACHE:
374
  if ( defined( 'LITESPEED_ON' ) && ( $_can_network_option || ( ! $_is_multisite && $_can_option ) ) ) {
375
  self::$_action = $action ;
376
  }
346
  }
347
  return ;
348
 
 
 
 
 
349
  case LiteSpeed_Cache::ACTION_PURGE_BY:
 
350
  case LiteSpeed_Cache::ACTION_FRONT_EXCLUDE:
351
  if ( defined( 'LITESPEED_ON' ) && ( $_can_network_option || $_can_option || self::is_ajax() ) ) {//here may need more security
352
  self::$_action = $action ;
353
  }
354
  return ;
355
 
 
 
 
 
 
 
356
  case LiteSpeed_Cache::ACTION_DB_OPTIMIZE:
357
  if ( $_can_network_option || $_can_option ) {
358
  self::$_action = $action ;
359
  }
360
  return ;
361
 
362
+ case LiteSpeed_Cache::ACTION_PURGE_EMPTYCACHE:// todo: moved to purge.cls type action
363
  if ( defined( 'LITESPEED_ON' ) && ( $_can_network_option || ( ! $_is_multisite && $_can_option ) ) ) {
364
  self::$_action = $action ;
365
  }
includes/litespeed-cache.class.php CHANGED
@@ -19,7 +19,7 @@ class LiteSpeed_Cache
19
  private static $_instance ;
20
 
21
  const PLUGIN_NAME = 'litespeed-cache' ;
22
- const PLUGIN_VERSION = '2.1.2' ;
23
 
24
  const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
25
 
@@ -29,12 +29,7 @@ class LiteSpeed_Cache
29
  const ACTION_SAVE_HTACCESS = 'save-htaccess' ;
30
  const ACTION_SAVE_SETTINGS = 'save-settings' ;
31
  const ACTION_SAVE_SETTINGS_NETWORK = 'save-settings-network' ;
32
- const ACTION_PURGE_ERRORS = 'PURGE_ERRORS' ;
33
- const ACTION_PURGE_PAGES = 'PURGE_PAGES' ;
34
- const ACTION_PURGE_CSSJS = 'PURGE_CSSJS' ;
35
  const ACTION_PURGE_BY = 'PURGE_BY' ;
36
- const ACTION_PURGE_FRONT = 'PURGE_FRONT' ;
37
- const ACTION_PURGE_ALL = 'PURGE_ALL' ;
38
  const ACTION_PURGE_EMPTYCACHE = 'PURGE_EMPTYCACHE' ;
39
  const ACTION_QS_PURGE = 'PURGE' ;
40
  const ACTION_QS_PURGE_SINGLE = 'PURGESINGLE' ;
@@ -50,7 +45,6 @@ class LiteSpeed_Cache
50
  const ACTION_CDN_CLOUDFLARE = 'cdn_cloudflare' ;
51
  const ACTION_CDN_QUICCLOUD = 'cdn_quiccloud' ;
52
 
53
- const ACTION_FRONT_PURGE = 'front-purge' ;
54
  const ACTION_FRONT_EXCLUDE = 'front-exclude' ;
55
 
56
  const ACTION_DB_OPTIMIZE = 'db_optimize' ;
@@ -99,6 +93,10 @@ class LiteSpeed_Cache
99
  include_once LSCWP_DIR . 'thirdparty/lscwp-registry-3rd.php' ;
100
  }
101
 
 
 
 
 
102
  /**
103
  * This needs to be before activation because admin-rules.class.php need const `LSCWP_CONTENT_FOLDER`
104
  * @since 1.9.1 Moved up
@@ -120,7 +118,7 @@ class LiteSpeed_Cache
120
  // Check if there is a purge request in queue
121
  if ( $purge_queue = get_option( LiteSpeed_Cache_Purge::PURGE_QUEUE ) ) {
122
  @header( $purge_queue ) ;
123
- LiteSpeed_Cache_Log::debug( '[Boot] Purge Queue found&sent: ' . $purge_queue ) ;
124
  delete_option( LiteSpeed_Cache_Purge::PURGE_QUEUE ) ;
125
  }
126
 
@@ -171,6 +169,11 @@ class LiteSpeed_Cache
171
  // return ;
172
  // }
173
 
 
 
 
 
 
174
  ob_start( array( $this, 'send_headers_force' ) ) ;
175
  add_action( 'shutdown', array( $this, 'send_headers' ), 0 ) ;
176
  add_action( 'wp_footer', 'LiteSpeed_Cache::footer_hook' ) ;
@@ -264,30 +267,8 @@ class LiteSpeed_Cache
264
  $msg = __( 'Crawler blacklist is saved.', 'litespeed-cache' ) ;
265
  break ;
266
 
267
- case LiteSpeed_Cache::ACTION_PURGE_FRONT:
268
- LiteSpeed_Cache_Purge::purge_front() ;
269
- $msg = __( 'Notified LiteSpeed Web Server to purge the front page.', 'litespeed-cache' ) ;
270
- break ;
271
-
272
- case LiteSpeed_Cache::ACTION_PURGE_PAGES:
273
- LiteSpeed_Cache_Purge::purge_pages() ;
274
- $msg = __( 'Notified LiteSpeed Web Server to purge pages.', 'litespeed-cache' ) ;
275
- break ;
276
-
277
- case LiteSpeed_Cache::ACTION_PURGE_CSSJS:
278
- LiteSpeed_Cache_Purge::purge_cssjs() ;
279
- $msg = __( 'Notified LiteSpeed Web Server to purge CSS/JS entries.', 'litespeed-cache' ) ;
280
- break ;
281
-
282
- case LiteSpeed_Cache::ACTION_PURGE_ERRORS:
283
- LiteSpeed_Cache_Purge::purge_errors() ;
284
- $msg = __( 'Notified LiteSpeed Web Server to purge error pages.', 'litespeed-cache' ) ;
285
- break ;
286
-
287
- case LiteSpeed_Cache::ACTION_PURGE_ALL:
288
  case LiteSpeed_Cache::ACTION_QS_PURGE_ALL:
289
  LiteSpeed_Cache_Purge::purge_all() ;
290
- $msg = __( 'Notified LiteSpeed Web Server to purge all caches.', 'litespeed-cache' ) ;
291
  break;
292
 
293
  case LiteSpeed_Cache::ACTION_PURGE_EMPTYCACHE:
@@ -297,11 +278,6 @@ class LiteSpeed_Cache
297
  $msg = __( 'Notified LiteSpeed Web Server to purge everything.', 'litespeed-cache' ) ;
298
  break;
299
 
300
- case LiteSpeed_Cache::ACTION_FRONT_PURGE:
301
- // redirect inside
302
- LiteSpeed_Cache_Purge::frontend_purge() ;
303
- break ;
304
-
305
  case LiteSpeed_Cache::ACTION_FRONT_EXCLUDE:
306
  // redirect inside
307
  LiteSpeed_Cache_Config::frontend_save() ;
@@ -440,7 +416,7 @@ class LiteSpeed_Cache
440
  */
441
  public static function footer_hook()
442
  {
443
- LiteSpeed_Cache_Log::debug( '[Boot] Footer hook called' ) ;
444
  if ( ! defined( 'LITESPEED_FOOTER_CALLED' ) ) {
445
  define( 'LITESPEED_FOOTER_CALLED', true ) ;
446
  }
@@ -455,22 +431,22 @@ class LiteSpeed_Cache
455
  private function _check_is_html( $buffer = null )
456
  {
457
  if ( ! defined( 'LITESPEED_FOOTER_CALLED' ) ) {
458
- LiteSpeed_Cache_Log::debug2( '[Boot] CHK html bypass: miss footer const' ) ;
459
  return ;
460
  }
461
 
462
  if ( defined( 'DOING_AJAX' ) ) {
463
- LiteSpeed_Cache_Log::debug2( '[Boot] CHK html bypass: doing ajax' ) ;
464
  return ;
465
  }
466
 
467
  if ( defined( 'DOING_CRON' ) ) {
468
- LiteSpeed_Cache_Log::debug2( '[Boot] CHK html bypass: doing cron' ) ;
469
  return ;
470
  }
471
 
472
  if ( $_SERVER[ 'REQUEST_METHOD' ] !== 'GET' ) {
473
- LiteSpeed_Cache_Log::debug2( '[Boot] CHK html bypass: not get method ' . $_SERVER[ 'REQUEST_METHOD' ] ) ;
474
  return ;
475
  }
476
 
@@ -489,11 +465,11 @@ class LiteSpeed_Cache
489
  $is_html = stripos( $buffer, '<html' ) === 0 || stripos( $buffer, '<!DOCTYPE' ) === 0 ;
490
 
491
  if ( ! $is_html ) {
492
- LiteSpeed_Cache_Log::debug( '[Boot] Footer check failed: ' . ob_get_level() . '-' . substr( $buffer, 0, 100 ) ) ;
493
  return ;
494
  }
495
 
496
- LiteSpeed_Cache_Log::debug( '[Boot] Footer check passed' ) ;
497
 
498
  if ( ! defined( 'LITESPEED_IS_HTML' ) ) {
499
  define( 'LITESPEED_IS_HTML', true ) ;
@@ -581,7 +557,7 @@ class LiteSpeed_Cache
581
  $running_info_showing = ( defined( 'LITESPEED_IS_HTML' ) && LITESPEED_IS_HTML ) || ( defined( 'LSCACHE_IS_ESI' ) && LSCACHE_IS_ESI ) ;
582
  if ( defined( 'LSCACHE_ESI_SILENCE' ) ) {
583
  $running_info_showing = false ;
584
- LiteSpeed_Cache_Log::debug( '[Boot] ESI silence' ) ;
585
  }
586
 
587
  if ( $running_info_showing ) {
19
  private static $_instance ;
20
 
21
  const PLUGIN_NAME = 'litespeed-cache' ;
22
+ const PLUGIN_VERSION = '2.2' ;
23
 
24
  const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
25
 
29
  const ACTION_SAVE_HTACCESS = 'save-htaccess' ;
30
  const ACTION_SAVE_SETTINGS = 'save-settings' ;
31
  const ACTION_SAVE_SETTINGS_NETWORK = 'save-settings-network' ;
 
 
 
32
  const ACTION_PURGE_BY = 'PURGE_BY' ;
 
 
33
  const ACTION_PURGE_EMPTYCACHE = 'PURGE_EMPTYCACHE' ;
34
  const ACTION_QS_PURGE = 'PURGE' ;
35
  const ACTION_QS_PURGE_SINGLE = 'PURGESINGLE' ;
45
  const ACTION_CDN_CLOUDFLARE = 'cdn_cloudflare' ;
46
  const ACTION_CDN_QUICCLOUD = 'cdn_quiccloud' ;
47
 
 
48
  const ACTION_FRONT_EXCLUDE = 'front-exclude' ;
49
 
50
  const ACTION_DB_OPTIMIZE = 'db_optimize' ;
93
  include_once LSCWP_DIR . 'thirdparty/lscwp-registry-3rd.php' ;
94
  }
95
 
96
+ if ( self::config( LiteSpeed_Cache_Config::OPID_DEBUG_DISABLE_ALL ) ) {
97
+ define( 'LITESPEED_DISABLE_ALL', true ) ;
98
+ }
99
+
100
  /**
101
  * This needs to be before activation because admin-rules.class.php need const `LSCWP_CONTENT_FOLDER`
102
  * @since 1.9.1 Moved up
118
  // Check if there is a purge request in queue
119
  if ( $purge_queue = get_option( LiteSpeed_Cache_Purge::PURGE_QUEUE ) ) {
120
  @header( $purge_queue ) ;
121
+ LiteSpeed_Cache_Log::debug( '[Core] Purge Queue found&sent: ' . $purge_queue ) ;
122
  delete_option( LiteSpeed_Cache_Purge::PURGE_QUEUE ) ;
123
  }
124
 
169
  // return ;
170
  // }
171
 
172
+ if ( defined( 'LITESPEED_DISABLE_ALL' ) ) {
173
+ LiteSpeed_Cache_Log::debug( '[Core] Bypassed due to debug disable all setting' ) ;
174
+ return ;
175
+ }
176
+
177
  ob_start( array( $this, 'send_headers_force' ) ) ;
178
  add_action( 'shutdown', array( $this, 'send_headers' ), 0 ) ;
179
  add_action( 'wp_footer', 'LiteSpeed_Cache::footer_hook' ) ;
267
  $msg = __( 'Crawler blacklist is saved.', 'litespeed-cache' ) ;
268
  break ;
269
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270
  case LiteSpeed_Cache::ACTION_QS_PURGE_ALL:
271
  LiteSpeed_Cache_Purge::purge_all() ;
 
272
  break;
273
 
274
  case LiteSpeed_Cache::ACTION_PURGE_EMPTYCACHE:
278
  $msg = __( 'Notified LiteSpeed Web Server to purge everything.', 'litespeed-cache' ) ;
279
  break;
280
 
 
 
 
 
 
281
  case LiteSpeed_Cache::ACTION_FRONT_EXCLUDE:
282
  // redirect inside
283
  LiteSpeed_Cache_Config::frontend_save() ;
416
  */
417
  public static function footer_hook()
418
  {
419
+ LiteSpeed_Cache_Log::debug( '[Core] Footer hook called' ) ;
420
  if ( ! defined( 'LITESPEED_FOOTER_CALLED' ) ) {
421
  define( 'LITESPEED_FOOTER_CALLED', true ) ;
422
  }
431
  private function _check_is_html( $buffer = null )
432
  {
433
  if ( ! defined( 'LITESPEED_FOOTER_CALLED' ) ) {
434
+ LiteSpeed_Cache_Log::debug2( '[Core] CHK html bypass: miss footer const' ) ;
435
  return ;
436
  }
437
 
438
  if ( defined( 'DOING_AJAX' ) ) {
439
+ LiteSpeed_Cache_Log::debug2( '[Core] CHK html bypass: doing ajax' ) ;
440
  return ;
441
  }
442
 
443
  if ( defined( 'DOING_CRON' ) ) {
444
+ LiteSpeed_Cache_Log::debug2( '[Core] CHK html bypass: doing cron' ) ;
445
  return ;
446
  }
447
 
448
  if ( $_SERVER[ 'REQUEST_METHOD' ] !== 'GET' ) {
449
+ LiteSpeed_Cache_Log::debug2( '[Core] CHK html bypass: not get method ' . $_SERVER[ 'REQUEST_METHOD' ] ) ;
450
  return ;
451
  }
452
 
465
  $is_html = stripos( $buffer, '<html' ) === 0 || stripos( $buffer, '<!DOCTYPE' ) === 0 ;
466
 
467
  if ( ! $is_html ) {
468
+ LiteSpeed_Cache_Log::debug( '[Core] Footer check failed: ' . ob_get_level() . '-' . substr( $buffer, 0, 100 ) ) ;
469
  return ;
470
  }
471
 
472
+ LiteSpeed_Cache_Log::debug( '[Core] Footer check passed' ) ;
473
 
474
  if ( ! defined( 'LITESPEED_IS_HTML' ) ) {
475
  define( 'LITESPEED_IS_HTML', true ) ;
557
  $running_info_showing = ( defined( 'LITESPEED_IS_HTML' ) && LITESPEED_IS_HTML ) || ( defined( 'LSCACHE_IS_ESI' ) && LSCACHE_IS_ESI ) ;
558
  if ( defined( 'LSCACHE_ESI_SILENCE' ) ) {
559
  $running_info_showing = false ;
560
+ LiteSpeed_Cache_Log::debug( '[Core] ESI silence' ) ;
561
  }
562
 
563
  if ( $running_info_showing ) {
languages/litespeed-cache.pot CHANGED
@@ -2,9 +2,9 @@
2
  # This file is distributed under the same license as the LiteSpeed Cache package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: LiteSpeed Cache 2.1.2\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/litespeed-cache\n"
7
- "POT-Creation-Date: 2018-03-28 15:43:27+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -30,14 +30,14 @@ msgstr ""
30
 
31
  #: admin/litespeed-cache-admin-display.class.php:151
32
  #: admin/tpl/setting/settings_cdn.php:204
33
- #: admin/tpl/setting/settings_cdn.php:247 inc/gui.class.php:349
34
- #: includes/litespeed-cache-gui.class.php:349
35
  msgid "Manage"
36
  msgstr ""
37
 
38
  #: admin/litespeed-cache-admin-display.class.php:153
39
- #: admin/litespeed-cache-admin-display.class.php:242 inc/gui.class.php:357
40
- #: includes/litespeed-cache-gui.class.php:357
41
  msgid "Settings"
42
  msgstr ""
43
 
@@ -45,8 +45,8 @@ msgstr ""
45
  msgid "Edit .htaccess"
46
  msgstr ""
47
 
48
- #: admin/litespeed-cache-admin-display.class.php:160 inc/gui.class.php:366
49
- #: includes/litespeed-cache-gui.class.php:366
50
  msgid "Image Optimization"
51
  msgstr ""
52
 
@@ -63,7 +63,7 @@ msgid "Import / Export"
63
  msgstr ""
64
 
65
  #: admin/litespeed-cache-admin-display.class.php:166
66
- #: admin/tpl/setting/settings_debug.php:13
67
  msgid "Debug Log"
68
  msgstr ""
69
 
@@ -74,6 +74,7 @@ msgstr ""
74
 
75
  #: admin/litespeed-cache-admin-display.class.php:800
76
  #: admin/litespeed-cache-admin-display.class.php:885
 
77
  #: admin/tpl/setting/settings_inc.cache_mobile.php:67
78
  #: admin/tpl/setting/settings_media.php:73
79
  #: admin/tpl/setting/settings_optimize.php:160
@@ -84,6 +85,7 @@ msgstr ""
84
 
85
  #: admin/litespeed-cache-admin-display.class.php:801
86
  #: admin/litespeed-cache-admin-display.class.php:889
 
87
  #: admin/tpl/setting/settings_inc.cache_object.php:149
88
  #: admin/tpl/setting/settings_tuning.php:18
89
  #: admin/tpl/setting/settings_tuning.php:54
@@ -419,47 +421,47 @@ msgstr ""
419
  msgid "Site options saved."
420
  msgstr ""
421
 
422
- #: admin/litespeed-cache-admin-settings.class.php:353
423
- #: admin/litespeed-cache-admin-settings.class.php:1009
424
  msgid "Default Public Cache"
425
  msgstr ""
426
 
427
- #: admin/litespeed-cache-admin-settings.class.php:354
428
  msgid "Default Private Cache"
429
  msgstr ""
430
 
431
- #: admin/litespeed-cache-admin-settings.class.php:355
432
  msgid "Default Front Page"
433
  msgstr ""
434
 
435
- #: admin/litespeed-cache-admin-settings.class.php:356
436
  msgid "Feed"
437
  msgstr ""
438
 
439
- #: admin/litespeed-cache-admin-settings.class.php:859
440
- #: admin/tpl/setting/settings_debug.php:78
441
  msgid "Log File Size Limit"
442
  msgstr ""
443
 
444
- #: admin/litespeed-cache-admin-settings.class.php:932
445
  #: admin/tpl/setting/settings_crawler.php:13
446
  msgid "Delay"
447
  msgstr ""
448
 
449
- #: admin/litespeed-cache-admin-settings.class.php:933
450
  #: admin/tpl/setting/settings_crawler.php:37
451
  msgid "Run Duration"
452
  msgstr ""
453
 
454
- #: admin/litespeed-cache-admin-settings.class.php:934
455
  msgid "Cron Interval"
456
  msgstr ""
457
 
458
- #: admin/litespeed-cache-admin-settings.class.php:935
459
  msgid "Whole Interval"
460
  msgstr ""
461
 
462
- #: admin/litespeed-cache-admin-settings.class.php:936
463
  #: admin/tpl/setting/settings_crawler.php:73
464
  msgid "Threads"
465
  msgstr ""
@@ -655,7 +657,7 @@ msgstr ""
655
  msgid "Sitemap Generation Blacklist"
656
  msgstr ""
657
 
658
- #: admin/tpl/crawler.php:250 admin/tpl/edit_htaccess.php:70
659
  msgid "Save"
660
  msgstr ""
661
 
@@ -677,31 +679,31 @@ msgstr ""
677
  msgid "Clear Log"
678
  msgstr ""
679
 
680
- #: admin/tpl/edit_htaccess.php:32
681
  msgid "LiteSpeed Cache Edit .htaccess"
682
  msgstr ""
683
 
684
- #: admin/tpl/edit_htaccess.php:42
685
  msgid "WARNING: This page is meant for advanced users."
686
  msgstr ""
687
 
688
- #: admin/tpl/edit_htaccess.php:44
689
  msgid "Any changes made to the .htaccess file may break the site."
690
  msgstr ""
691
 
692
- #: admin/tpl/edit_htaccess.php:45
693
  msgid "Please consult the host/server admin before making any changes."
694
  msgstr ""
695
 
696
- #: admin/tpl/edit_htaccess.php:50
697
  msgid "File editing is disabled in configuration."
698
  msgstr ""
699
 
700
- #: admin/tpl/edit_htaccess.php:60
701
  msgid "Current %s Contents"
702
  msgstr ""
703
 
704
- #: admin/tpl/edit_htaccess.php:62
705
  msgid "DO NOT EDIT ANYTHING WITHIN %s"
706
  msgstr ""
707
 
@@ -979,8 +981,8 @@ msgstr ""
979
  #: admin/tpl/setting/settings_crawler.php:22
980
  #: admin/tpl/setting/settings_crawler.php:95
981
  #: admin/tpl/setting/settings_crawler.php:100
982
- #: admin/tpl/setting/settings_excludes.php:66
983
- #: admin/tpl/setting/settings_excludes.php:104
984
  #: admin/tpl/setting/settings_inc.cache_browser.php:12
985
  #: admin/tpl/setting/settings_inc.cache_favicon.php:13
986
  #: admin/tpl/setting/settings_inc.cache_mobile.php:17
@@ -1042,10 +1044,10 @@ msgstr ""
1042
  msgid "Rate %s on %s"
1043
  msgstr ""
1044
 
1045
- #. #-#-#-#-# litespeed-cache.pot (LiteSpeed Cache 2.1.2) #-#-#-#-#
1046
  #. Plugin Name of the plugin/theme
1047
- #: admin/tpl/inc/admin_footer.php:6 inc/gui.class.php:341
1048
- #: includes/litespeed-cache-gui.class.php:341
1049
  msgid "LiteSpeed Cache"
1050
  msgstr ""
1051
 
@@ -1236,7 +1238,8 @@ msgid ""
1236
  "dismissed. (<a %3$s>Learn More</a>)"
1237
  msgstr ""
1238
 
1239
- #: admin/tpl/manage/manage_cdn.php:11
 
1240
  msgid "Cloudflare"
1241
  msgstr ""
1242
 
@@ -1404,114 +1407,124 @@ msgstr ""
1404
  msgid "This will Purge Pages only"
1405
  msgstr ""
1406
 
1407
- #: admin/tpl/manage/manage_purge.php:19 inc/gui.class.php:383
1408
- #: includes/litespeed-cache-gui.class.php:383
1409
- msgid "Purge CSS/JS Cache"
1410
- msgstr ""
1411
-
1412
- #: admin/tpl/manage/manage_purge.php:20
1413
- msgid "This will purge all minified/combined CSS/JS entries only"
1414
- msgstr ""
1415
-
1416
- #: admin/tpl/manage/manage_purge.php:25
1417
- msgid "Purge 403 Error"
1418
- msgstr ""
1419
-
1420
- #: admin/tpl/manage/manage_purge.php:26
1421
- msgid "Purge error pages, including 403 pages"
1422
  msgstr ""
1423
 
 
1424
  #: admin/tpl/manage/manage_purge.php:32
1425
- msgid "Purge 404 Error"
1426
  msgstr ""
1427
 
1428
  #: admin/tpl/manage/manage_purge.php:33
1429
- msgid "Purge error pages, including 404 pages"
1430
- msgstr ""
1431
-
1432
- #: admin/tpl/manage/manage_purge.php:39
1433
  msgid "Purge 500 Error"
1434
  msgstr ""
1435
 
1436
- #: admin/tpl/manage/manage_purge.php:40
1437
  msgid "Purge error pages, including 500 pages"
1438
  msgstr ""
1439
 
1440
- #: admin/tpl/manage/manage_purge.php:46
 
 
 
 
 
 
 
 
 
 
1441
  msgid "Purge All"
1442
  msgstr ""
1443
 
1444
- #: admin/tpl/manage/manage_purge.php:47
1445
- msgid "Purge the cache entries created by this plugin"
 
 
 
 
 
 
 
 
 
1446
  msgstr ""
1447
 
1448
- #: admin/tpl/manage/manage_purge.php:56 inc/gui.class.php:402
1449
- #: includes/litespeed-cache-gui.class.php:402
1450
- msgid "Object Cache Purge All"
 
1451
  msgstr ""
1452
 
1453
- #: admin/tpl/manage/manage_purge.php:57
1454
  msgid "Purge all the object caches"
1455
  msgstr ""
1456
 
1457
- #: admin/tpl/manage/manage_purge.php:66 inc/gui.class.php:412
1458
- #: includes/litespeed-cache-gui.class.php:412
1459
- msgid "Opcode Cache Purge All"
1460
  msgstr ""
1461
 
1462
- #: admin/tpl/manage/manage_purge.php:67
1463
  msgid "Reset the entire opcode cache"
1464
  msgstr ""
1465
 
1466
- #: admin/tpl/manage/manage_purge.php:76
 
 
 
 
1467
  msgid "Empty Entire Cache"
1468
  msgstr ""
1469
 
1470
- #: admin/tpl/manage/manage_purge.php:77
1471
  msgid ""
1472
  "Clears all cache entries related to this site, <i>including other web "
1473
  "applications</i>."
1474
  msgstr ""
1475
 
1476
- #: admin/tpl/manage/manage_purge.php:78
1477
  msgid "This action should only be used if things are cached incorrectly."
1478
  msgstr ""
1479
 
1480
- #: admin/tpl/manage/manage_purge.php:83
1481
  msgid "This will clear EVERYTHING inside the cache."
1482
  msgstr ""
1483
 
1484
- #: admin/tpl/manage/manage_purge.php:84
1485
  msgid "This may cause heavy load on the server."
1486
  msgstr ""
1487
 
1488
- #: admin/tpl/manage/manage_purge.php:85
1489
  msgid "If only the WordPress site should be purged, use purge all."
1490
  msgstr ""
1491
 
1492
- #: admin/tpl/manage/manage_purge.php:93 admin/tpl/manage.php:5
1493
  #: admin/tpl/network_settings.php:7 admin/tpl/settings.php:7
1494
  msgid "Purge"
1495
  msgstr ""
1496
 
1497
- #: admin/tpl/manage/manage_purge.php:124
1498
  msgid "Purge By..."
1499
  msgstr ""
1500
 
1501
- #: admin/tpl/manage/manage_purge.php:126
1502
  msgid "Select below for \"Purge by\" options."
1503
  msgstr ""
1504
 
1505
- #: admin/tpl/manage/manage_purge.php:127
1506
  #: admin/tpl/setting/settings_cache.php:73
1507
  #: admin/tpl/setting/settings_cache.php:90
1508
  #: admin/tpl/setting/settings_cdn.php:116
1509
  #: admin/tpl/setting/settings_cdn.php:143
1510
  #: admin/tpl/setting/settings_crawler.php:132
1511
  #: admin/tpl/setting/settings_excludes.php:25
1512
- #: admin/tpl/setting/settings_excludes.php:39
1513
- #: admin/tpl/setting/settings_excludes.php:62
1514
- #: admin/tpl/setting/settings_excludes.php:100
 
1515
  #: admin/tpl/setting/settings_inc.cache_object.php:114
1516
  #: admin/tpl/setting/settings_inc.cache_object.php:122
1517
  #: admin/tpl/setting/settings_inc.exclude_cookies.php:19
@@ -1525,44 +1538,44 @@ msgstr ""
1525
  msgid "One per line."
1526
  msgstr ""
1527
 
1528
- #: admin/tpl/manage/manage_purge.php:154
1529
  msgid "Category"
1530
  msgstr ""
1531
 
1532
- #: admin/tpl/manage/manage_purge.php:160
1533
  msgid "Post ID"
1534
  msgstr ""
1535
 
1536
- #: admin/tpl/manage/manage_purge.php:166
1537
  msgid "Tag"
1538
  msgstr ""
1539
 
1540
- #: admin/tpl/manage/manage_purge.php:172
1541
  msgid "URL"
1542
  msgstr ""
1543
 
1544
- #: admin/tpl/manage/manage_purge.php:178
1545
  msgid ""
1546
  "Purge pages by category name - e.g. %2$s should be used for the URL %1$s."
1547
  msgstr ""
1548
 
1549
- #: admin/tpl/manage/manage_purge.php:183
1550
  msgid "Purge pages by post ID."
1551
  msgstr ""
1552
 
1553
- #: admin/tpl/manage/manage_purge.php:187
1554
  msgid "Purge pages by tag name - e.g. %2$s should be used for the URL %1$s."
1555
  msgstr ""
1556
 
1557
- #: admin/tpl/manage/manage_purge.php:192
1558
  msgid "Purge pages by relative or full URL."
1559
  msgstr ""
1560
 
1561
- #: admin/tpl/manage/manage_purge.php:193
1562
  msgid "e.g. Use %s or %s."
1563
  msgstr ""
1564
 
1565
- #: admin/tpl/manage/manage_purge.php:206
1566
  msgid "Purge List"
1567
  msgstr ""
1568
 
@@ -1600,7 +1613,7 @@ msgstr ""
1600
  msgid "Media"
1601
  msgstr ""
1602
 
1603
- #: admin/tpl/network_settings.php:10 admin/tpl/setting/settings_debug.php:68
1604
  #: admin/tpl/settings.php:14
1605
  msgid "Advanced"
1606
  msgstr ""
@@ -1809,22 +1822,26 @@ msgstr ""
1809
 
1810
  #: admin/tpl/setting/settings_cache.php:67
1811
  #: admin/tpl/setting/settings_excludes.php:19
 
1812
  msgid "The URLs will be compared to the REQUEST_URI server variable."
1813
  msgstr ""
1814
 
1815
  #: admin/tpl/setting/settings_cache.php:68
1816
  #: admin/tpl/setting/settings_excludes.php:20
 
1817
  #: admin/tpl/setting/settings_tuning.php:174
1818
  msgid "For example, for %s, %s can be used here."
1819
  msgstr ""
1820
 
1821
  #: admin/tpl/setting/settings_cache.php:71
1822
  #: admin/tpl/setting/settings_excludes.php:23
 
1823
  msgid "To match the beginning, add %s to the beginning of the item."
1824
  msgstr ""
1825
 
1826
  #: admin/tpl/setting/settings_cache.php:72
1827
  #: admin/tpl/setting/settings_excludes.php:24
 
1828
  msgid "To do an exact match, add %s to the end of the URL."
1829
  msgstr ""
1830
 
@@ -1948,7 +1965,6 @@ msgid "Load JQuery Remotely"
1948
  msgstr ""
1949
 
1950
  #: admin/tpl/setting/settings_cdn.php:155
1951
- #: admin/tpl/setting/settings_debug.php:19
1952
  msgid "Off"
1953
  msgstr ""
1954
 
@@ -2235,125 +2251,130 @@ msgstr ""
2235
  msgid "Developer Testing"
2236
  msgstr ""
2237
 
2238
- #: admin/tpl/setting/settings_debug.php:25
2239
- msgid "On"
 
 
 
 
 
2240
  msgstr ""
2241
 
2242
- #: admin/tpl/setting/settings_debug.php:31
2243
  msgid "Admin IP only"
2244
  msgstr ""
2245
 
2246
- #: admin/tpl/setting/settings_debug.php:35
2247
  msgid "Outputs to WordPress debug log."
2248
  msgstr ""
2249
 
2250
- #: admin/tpl/setting/settings_debug.php:36
2251
  msgid ""
2252
  "This should be set to off once everything is working to prevent filling the "
2253
  "disk."
2254
  msgstr ""
2255
 
2256
- #: admin/tpl/setting/settings_debug.php:37
2257
  msgid ""
2258
  "The Admin IP option will only output log messages on requests from admin IPs."
2259
  msgstr ""
2260
 
2261
- #: admin/tpl/setting/settings_debug.php:38
2262
  msgid "The logs will be outputted to %s."
2263
  msgstr ""
2264
 
2265
- #: admin/tpl/setting/settings_debug.php:44
2266
  msgid "Admin IPs"
2267
  msgstr ""
2268
 
2269
- #: admin/tpl/setting/settings_debug.php:48
2270
  msgid ""
2271
  "Allows listed IPs (one per line) to perform certain actions from their "
2272
  "browsers."
2273
  msgstr ""
2274
 
2275
- #: admin/tpl/setting/settings_debug.php:49
2276
  msgid ""
2277
  "More information about the available commands can be found <a %s>here</a>."
2278
  msgstr ""
2279
 
2280
- #: admin/tpl/setting/settings_debug.php:56
2281
  msgid "Debug Level"
2282
  msgstr ""
2283
 
2284
- #: admin/tpl/setting/settings_debug.php:62
2285
  msgid "Basic"
2286
  msgstr ""
2287
 
2288
- #: admin/tpl/setting/settings_debug.php:72
2289
  msgid "Advanced level will log more details."
2290
  msgstr ""
2291
 
2292
- #: admin/tpl/setting/settings_debug.php:81
2293
  #: admin/tpl/setting/settings_tuning.php:88
2294
  msgid "MB"
2295
  msgstr ""
2296
 
2297
- #: admin/tpl/setting/settings_debug.php:83
2298
  msgid ""
2299
  "Specify the maximum size of the log file. Minimum is 3MB. Maximum is 3000MB."
2300
  msgstr ""
2301
 
2302
- #: admin/tpl/setting/settings_debug.php:90
2303
  msgid "Heartbeat"
2304
  msgstr ""
2305
 
2306
- #: admin/tpl/setting/settings_debug.php:94
2307
  msgid ""
2308
  "Disable WordPress heartbeat to prevent AJAX calls from breaking debug "
2309
  "logging. WARNING: Disabling this may cause WordPress tasks triggered by AJAX "
2310
  "to stop working."
2311
  msgstr ""
2312
 
2313
- #: admin/tpl/setting/settings_debug.php:100
2314
  msgid "Log Cookies"
2315
  msgstr ""
2316
 
2317
- #: admin/tpl/setting/settings_debug.php:104
2318
  msgid "Log request cookie values."
2319
  msgstr ""
2320
 
2321
- #: admin/tpl/setting/settings_debug.php:110
2322
  msgid "Collapse Query Strings"
2323
  msgstr ""
2324
 
2325
- #: admin/tpl/setting/settings_debug.php:114
2326
  msgid "Shorten query strings in the debug log to improve readability."
2327
  msgstr ""
2328
 
2329
- #: admin/tpl/setting/settings_debug.php:120
2330
  msgid "Log Filters"
2331
  msgstr ""
2332
 
2333
- #: admin/tpl/setting/settings_debug.php:124
2334
  msgid ""
2335
  "Log all WordPress filter hooks. WARNING: Enabling this option will cause log "
2336
  "file size to grow quickly."
2337
  msgstr ""
2338
 
2339
- #: admin/tpl/setting/settings_debug.php:130
2340
  msgid "Exclude Filters"
2341
  msgstr ""
2342
 
2343
- #: admin/tpl/setting/settings_debug.php:134
2344
  msgid "Listed filters (one per line) will not be logged."
2345
  msgstr ""
2346
 
2347
- #: admin/tpl/setting/settings_debug.php:135
2348
- #: admin/tpl/setting/settings_debug.php:146
2349
  msgid "Recommended default value"
2350
  msgstr ""
2351
 
2352
- #: admin/tpl/setting/settings_debug.php:141
2353
  msgid "Exclude Part Filters"
2354
  msgstr ""
2355
 
2356
- #: admin/tpl/setting/settings_debug.php:145
2357
  msgid "Filters containing these strings (one per line) will not be logged."
2358
  msgstr ""
2359
 
@@ -2425,81 +2446,91 @@ msgid ""
2425
  msgstr ""
2426
 
2427
  #: admin/tpl/setting/settings_excludes.php:6
2428
- msgid "Do Not Cache Settings"
2429
  msgstr ""
2430
 
2431
  #: admin/tpl/setting/settings_excludes.php:14
2432
- msgid "Do Not Cache URIs"
2433
  msgstr ""
2434
 
2435
  #: admin/tpl/setting/settings_excludes.php:18
2436
- msgid "Paths containing these strings will not be cached."
 
 
2437
  msgstr ""
2438
 
2439
  #: admin/tpl/setting/settings_excludes.php:32
2440
- msgid "Do Not Cache Query Strings"
2441
  msgstr ""
2442
 
2443
  #: admin/tpl/setting/settings_excludes.php:36
 
 
 
 
 
 
 
 
2444
  msgid "Query string containing these parameters will not be cached."
2445
  msgstr ""
2446
 
2447
- #: admin/tpl/setting/settings_excludes.php:37
2448
  msgid "For example, for %s, %s and %s can be used here."
2449
  msgstr ""
2450
 
2451
- #: admin/tpl/setting/settings_excludes.php:46
2452
  msgid "Do Not Cache Categories"
2453
  msgstr ""
2454
 
2455
- #: admin/tpl/setting/settings_excludes.php:59
2456
  msgid "All categories are cached by default."
2457
  msgstr ""
2458
 
2459
- #: admin/tpl/setting/settings_excludes.php:60
2460
- #: admin/tpl/setting/settings_excludes.php:98
2461
  #: admin/tpl/setting/settings_inc.exclude_cookies.php:16
2462
  #: admin/tpl/setting/settings_inc.exclude_useragent.php:15
2463
  msgid "To prevent %s from being cached, enter it here."
2464
  msgstr ""
2465
 
2466
- #: admin/tpl/setting/settings_excludes.php:60
2467
  msgid "categories"
2468
  msgstr ""
2469
 
2470
- #: admin/tpl/setting/settings_excludes.php:68
2471
  msgid ""
2472
  "If the category slug is not found, the category will be removed from the "
2473
  "list on save."
2474
  msgstr ""
2475
 
2476
- #: admin/tpl/setting/settings_excludes.php:69
2477
- #: admin/tpl/setting/settings_excludes.php:107
2478
  msgid "To exclude %1$s, insert %2$s."
2479
  msgstr ""
2480
 
2481
- #: admin/tpl/setting/settings_excludes.php:77
2482
  msgid "Do Not Cache Tags"
2483
  msgstr ""
2484
 
2485
- #: admin/tpl/setting/settings_excludes.php:97
2486
  msgid "All tags are cached by default."
2487
  msgstr ""
2488
 
2489
- #: admin/tpl/setting/settings_excludes.php:98
2490
  msgid "tags"
2491
  msgstr ""
2492
 
2493
- #: admin/tpl/setting/settings_excludes.php:106
2494
  msgid ""
2495
  "If the tag slug is not found, the tag will be removed from the list on save."
2496
  msgstr ""
2497
 
2498
- #: admin/tpl/setting/settings_excludes.php:127
2499
  msgid "Do Not Cache Roles"
2500
  msgstr ""
2501
 
2502
- #: admin/tpl/setting/settings_excludes.php:133
2503
  msgid "Selected roles will be excluded from cache."
2504
  msgstr ""
2505
 
@@ -2714,10 +2745,6 @@ msgstr ""
2714
  msgid "Failed"
2715
  msgstr ""
2716
 
2717
- #: admin/tpl/setting/settings_inc.cache_object.php:28
2718
- msgid "Object Cache"
2719
- msgstr ""
2720
-
2721
  #: admin/tpl/setting/settings_inc.cache_object.php:32
2722
  msgid "Use object cache functionality."
2723
  msgstr ""
@@ -3663,31 +3690,31 @@ msgid "Mark this page as "
3663
  msgstr ""
3664
 
3665
  #: inc/gui.class.php:292 includes/litespeed-cache-gui.class.php:292
3666
- msgid "Non cacheable"
3667
  msgstr ""
3668
 
3669
  #: inc/gui.class.php:299 includes/litespeed-cache-gui.class.php:299
3670
- msgid "Private cache"
3671
  msgstr ""
3672
 
3673
  #: inc/gui.class.php:306 includes/litespeed-cache-gui.class.php:306
3674
- msgid "No optimization"
3675
  msgstr ""
3676
 
3677
  #: inc/gui.class.php:313 includes/litespeed-cache-gui.class.php:313
3678
- msgid "More settings"
3679
  msgstr ""
3680
 
3681
- #: inc/gui.class.php:333 includes/litespeed-cache-gui.class.php:333
3682
- msgid "LiteSpeed Cache Purge All"
3683
  msgstr ""
3684
 
3685
- #: inc/gui.class.php:375 includes/litespeed-cache-gui.class.php:375
3686
- msgid "LSCache Purge All"
3687
  msgstr ""
3688
 
3689
- #: inc/gui.class.php:392 includes/litespeed-cache-gui.class.php:392
3690
- msgid "Cloudflare Purge All"
3691
  msgstr ""
3692
 
3693
  #: inc/img_optm.class.php:80
@@ -3761,35 +3788,15 @@ msgstr ""
3761
  msgid "Imported setting file %s successfully."
3762
  msgstr ""
3763
 
3764
- #: inc/litespeed-cache.class.php:264 includes/litespeed-cache.class.php:264
3765
  msgid "Crawler blacklist is saved."
3766
  msgstr ""
3767
 
3768
- #: inc/litespeed-cache.class.php:269 includes/litespeed-cache.class.php:269
3769
- msgid "Notified LiteSpeed Web Server to purge the front page."
3770
- msgstr ""
3771
-
3772
- #: inc/litespeed-cache.class.php:274 includes/litespeed-cache.class.php:274
3773
- msgid "Notified LiteSpeed Web Server to purge pages."
3774
- msgstr ""
3775
-
3776
- #: inc/litespeed-cache.class.php:279 includes/litespeed-cache.class.php:279
3777
- msgid "Notified LiteSpeed Web Server to purge CSS/JS entries."
3778
- msgstr ""
3779
-
3780
- #: inc/litespeed-cache.class.php:284 includes/litespeed-cache.class.php:284
3781
- msgid "Notified LiteSpeed Web Server to purge error pages."
3782
- msgstr ""
3783
-
3784
- #: inc/litespeed-cache.class.php:290 includes/litespeed-cache.class.php:290
3785
- msgid "Notified LiteSpeed Web Server to purge all caches."
3786
- msgstr ""
3787
-
3788
- #: inc/litespeed-cache.class.php:297 includes/litespeed-cache.class.php:297
3789
  msgid "Notified LiteSpeed Web Server to purge everything."
3790
  msgstr ""
3791
 
3792
- #: inc/litespeed-cache.class.php:312 includes/litespeed-cache.class.php:312
3793
  msgid "Notified LiteSpeed Web Server to purge the list."
3794
  msgstr ""
3795
 
@@ -3821,35 +3828,59 @@ msgstr ""
3821
  msgid "Original saved %s"
3822
  msgstr ""
3823
 
3824
- #: inc/purge.class.php:64 includes/litespeed-cache-purge.class.php:64
 
 
 
 
 
 
 
 
 
 
 
 
3825
  msgid "Opcode cache is not enabled."
3826
  msgstr ""
3827
 
3828
- #: inc/purge.class.php:74 includes/litespeed-cache-purge.class.php:74
3829
  msgid "Reset the entire opcode cache successfully."
3830
  msgstr ""
3831
 
3832
- #: inc/purge.class.php:91 includes/litespeed-cache-purge.class.php:91
3833
  msgid "Object cache is not enabled."
3834
  msgstr ""
3835
 
3836
- #: inc/purge.class.php:99 includes/litespeed-cache-purge.class.php:99
3837
  msgid "Purge all object caches successfully."
3838
  msgstr ""
3839
 
3840
- #: inc/purge.class.php:294 includes/litespeed-cache-purge.class.php:294
 
 
 
 
 
 
 
 
 
 
 
 
3841
  msgid "Purge category %s"
3842
  msgstr ""
3843
 
3844
- #: inc/purge.class.php:321 includes/litespeed-cache-purge.class.php:321
3845
  msgid "Purge Post ID %s"
3846
  msgstr ""
3847
 
3848
- #: inc/purge.class.php:350 includes/litespeed-cache-purge.class.php:350
3849
  msgid "Purge tag %s"
3850
  msgstr ""
3851
 
3852
- #: inc/purge.class.php:384 includes/litespeed-cache-purge.class.php:384
3853
  msgid "Purge url %s"
3854
  msgstr ""
3855
 
2
  # This file is distributed under the same license as the LiteSpeed Cache package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: LiteSpeed Cache 2.2\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/litespeed-cache\n"
7
+ "POT-Creation-Date: 2018-04-02 18:57:20+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
30
 
31
  #: admin/litespeed-cache-admin-display.class.php:151
32
  #: admin/tpl/setting/settings_cdn.php:204
33
+ #: admin/tpl/setting/settings_cdn.php:247 inc/gui.class.php:356
34
+ #: includes/litespeed-cache-gui.class.php:356
35
  msgid "Manage"
36
  msgstr ""
37
 
38
  #: admin/litespeed-cache-admin-display.class.php:153
39
+ #: admin/litespeed-cache-admin-display.class.php:242 inc/gui.class.php:364
40
+ #: includes/litespeed-cache-gui.class.php:364
41
  msgid "Settings"
42
  msgstr ""
43
 
45
  msgid "Edit .htaccess"
46
  msgstr ""
47
 
48
+ #: admin/litespeed-cache-admin-display.class.php:160 inc/gui.class.php:373
49
+ #: includes/litespeed-cache-gui.class.php:373
50
  msgid "Image Optimization"
51
  msgstr ""
52
 
63
  msgstr ""
64
 
65
  #: admin/litespeed-cache-admin-display.class.php:166
66
+ #: admin/tpl/setting/settings_debug.php:23
67
  msgid "Debug Log"
68
  msgstr ""
69
 
74
 
75
  #: admin/litespeed-cache-admin-display.class.php:800
76
  #: admin/litespeed-cache-admin-display.class.php:885
77
+ #: admin/tpl/setting/settings_debug.php:35
78
  #: admin/tpl/setting/settings_inc.cache_mobile.php:67
79
  #: admin/tpl/setting/settings_media.php:73
80
  #: admin/tpl/setting/settings_optimize.php:160
85
 
86
  #: admin/litespeed-cache-admin-display.class.php:801
87
  #: admin/litespeed-cache-admin-display.class.php:889
88
+ #: admin/tpl/setting/settings_debug.php:29
89
  #: admin/tpl/setting/settings_inc.cache_object.php:149
90
  #: admin/tpl/setting/settings_tuning.php:18
91
  #: admin/tpl/setting/settings_tuning.php:54
421
  msgid "Site options saved."
422
  msgstr ""
423
 
424
+ #: admin/litespeed-cache-admin-settings.class.php:355
425
+ #: admin/litespeed-cache-admin-settings.class.php:1024
426
  msgid "Default Public Cache"
427
  msgstr ""
428
 
429
+ #: admin/litespeed-cache-admin-settings.class.php:356
430
  msgid "Default Private Cache"
431
  msgstr ""
432
 
433
+ #: admin/litespeed-cache-admin-settings.class.php:357
434
  msgid "Default Front Page"
435
  msgstr ""
436
 
437
+ #: admin/litespeed-cache-admin-settings.class.php:358
438
  msgid "Feed"
439
  msgstr ""
440
 
441
+ #: admin/litespeed-cache-admin-settings.class.php:866
442
+ #: admin/tpl/setting/settings_debug.php:88
443
  msgid "Log File Size Limit"
444
  msgstr ""
445
 
446
+ #: admin/litespeed-cache-admin-settings.class.php:947
447
  #: admin/tpl/setting/settings_crawler.php:13
448
  msgid "Delay"
449
  msgstr ""
450
 
451
+ #: admin/litespeed-cache-admin-settings.class.php:948
452
  #: admin/tpl/setting/settings_crawler.php:37
453
  msgid "Run Duration"
454
  msgstr ""
455
 
456
+ #: admin/litespeed-cache-admin-settings.class.php:949
457
  msgid "Cron Interval"
458
  msgstr ""
459
 
460
+ #: admin/litespeed-cache-admin-settings.class.php:950
461
  msgid "Whole Interval"
462
  msgstr ""
463
 
464
+ #: admin/litespeed-cache-admin-settings.class.php:951
465
  #: admin/tpl/setting/settings_crawler.php:73
466
  msgid "Threads"
467
  msgstr ""
657
  msgid "Sitemap Generation Blacklist"
658
  msgstr ""
659
 
660
+ #: admin/tpl/crawler.php:250 admin/tpl/edit_htaccess.php:69
661
  msgid "Save"
662
  msgstr ""
663
 
679
  msgid "Clear Log"
680
  msgstr ""
681
 
682
+ #: admin/tpl/edit_htaccess.php:31
683
  msgid "LiteSpeed Cache Edit .htaccess"
684
  msgstr ""
685
 
686
+ #: admin/tpl/edit_htaccess.php:41
687
  msgid "WARNING: This page is meant for advanced users."
688
  msgstr ""
689
 
690
+ #: admin/tpl/edit_htaccess.php:43
691
  msgid "Any changes made to the .htaccess file may break the site."
692
  msgstr ""
693
 
694
+ #: admin/tpl/edit_htaccess.php:44
695
  msgid "Please consult the host/server admin before making any changes."
696
  msgstr ""
697
 
698
+ #: admin/tpl/edit_htaccess.php:49
699
  msgid "File editing is disabled in configuration."
700
  msgstr ""
701
 
702
+ #: admin/tpl/edit_htaccess.php:59
703
  msgid "Current %s Contents"
704
  msgstr ""
705
 
706
+ #: admin/tpl/edit_htaccess.php:61
707
  msgid "DO NOT EDIT ANYTHING WITHIN %s"
708
  msgstr ""
709
 
981
  #: admin/tpl/setting/settings_crawler.php:22
982
  #: admin/tpl/setting/settings_crawler.php:95
983
  #: admin/tpl/setting/settings_crawler.php:100
984
+ #: admin/tpl/setting/settings_excludes.php:84
985
+ #: admin/tpl/setting/settings_excludes.php:122
986
  #: admin/tpl/setting/settings_inc.cache_browser.php:12
987
  #: admin/tpl/setting/settings_inc.cache_favicon.php:13
988
  #: admin/tpl/setting/settings_inc.cache_mobile.php:17
1044
  msgid "Rate %s on %s"
1045
  msgstr ""
1046
 
1047
+ #. #-#-#-#-# litespeed-cache.pot (LiteSpeed Cache 2.2) #-#-#-#-#
1048
  #. Plugin Name of the plugin/theme
1049
+ #: admin/tpl/inc/admin_footer.php:6 inc/gui.class.php:348
1050
+ #: includes/litespeed-cache-gui.class.php:348
1051
  msgid "LiteSpeed Cache"
1052
  msgstr ""
1053
 
1238
  "dismissed. (<a %3$s>Learn More</a>)"
1239
  msgstr ""
1240
 
1241
+ #: admin/tpl/manage/manage_cdn.php:11 inc/gui.class.php:407
1242
+ #: includes/litespeed-cache-gui.class.php:407
1243
  msgid "Cloudflare"
1244
  msgstr ""
1245
 
1407
  msgid "This will Purge Pages only"
1408
  msgstr ""
1409
 
1410
+ #: admin/tpl/manage/manage_purge.php:19 admin/tpl/manage/manage_purge.php:25
1411
+ #: admin/tpl/manage/manage_purge.php:31
1412
+ msgid "Purge %s Error"
 
 
 
 
 
 
 
 
 
 
 
 
1413
  msgstr ""
1414
 
1415
+ #: admin/tpl/manage/manage_purge.php:20 admin/tpl/manage/manage_purge.php:26
1416
  #: admin/tpl/manage/manage_purge.php:32
1417
+ msgid "Purge error pages, including %s pages"
1418
  msgstr ""
1419
 
1420
  #: admin/tpl/manage/manage_purge.php:33
 
 
 
 
1421
  msgid "Purge 500 Error"
1422
  msgstr ""
1423
 
1424
+ #: admin/tpl/manage/manage_purge.php:34
1425
  msgid "Purge error pages, including 500 pages"
1426
  msgstr ""
1427
 
1428
+ #: admin/tpl/manage/manage_purge.php:39 admin/tpl/manage/manage_purge.php:45
1429
+ #: admin/tpl/manage/manage_purge.php:54 admin/tpl/manage/manage_purge.php:63
1430
+ #: admin/tpl/manage/manage_purge.php:71 inc/gui.class.php:382
1431
+ #: inc/gui.class.php:390 inc/gui.class.php:398 inc/gui.class.php:407
1432
+ #: inc/gui.class.php:417 inc/gui.class.php:427
1433
+ #: includes/litespeed-cache-gui.class.php:382
1434
+ #: includes/litespeed-cache-gui.class.php:390
1435
+ #: includes/litespeed-cache-gui.class.php:398
1436
+ #: includes/litespeed-cache-gui.class.php:407
1437
+ #: includes/litespeed-cache-gui.class.php:417
1438
+ #: includes/litespeed-cache-gui.class.php:427
1439
  msgid "Purge All"
1440
  msgstr ""
1441
 
1442
+ #: admin/tpl/manage/manage_purge.php:40
1443
+ msgid "Purge the litespeed cache entries created by this plugin"
1444
+ msgstr ""
1445
+
1446
+ #: admin/tpl/manage/manage_purge.php:45 inc/gui.class.php:398
1447
+ #: includes/litespeed-cache-gui.class.php:398
1448
+ msgid "CSS/JS Cache"
1449
+ msgstr ""
1450
+
1451
+ #: admin/tpl/manage/manage_purge.php:46
1452
+ msgid "This will purge all minified/combined CSS/JS entries only"
1453
  msgstr ""
1454
 
1455
+ #: admin/tpl/manage/manage_purge.php:54
1456
+ #: admin/tpl/setting/settings_inc.cache_object.php:28 inc/gui.class.php:417
1457
+ #: includes/litespeed-cache-gui.class.php:417
1458
+ msgid "Object Cache"
1459
  msgstr ""
1460
 
1461
+ #: admin/tpl/manage/manage_purge.php:55
1462
  msgid "Purge all the object caches"
1463
  msgstr ""
1464
 
1465
+ #: admin/tpl/manage/manage_purge.php:63 inc/gui.class.php:427
1466
+ #: includes/litespeed-cache-gui.class.php:427
1467
+ msgid "Opcode Cache"
1468
  msgstr ""
1469
 
1470
+ #: admin/tpl/manage/manage_purge.php:64
1471
  msgid "Reset the entire opcode cache"
1472
  msgstr ""
1473
 
1474
+ #: admin/tpl/manage/manage_purge.php:72
1475
+ msgid "Purge the cache entries created by this plugin"
1476
+ msgstr ""
1477
+
1478
+ #: admin/tpl/manage/manage_purge.php:81
1479
  msgid "Empty Entire Cache"
1480
  msgstr ""
1481
 
1482
+ #: admin/tpl/manage/manage_purge.php:82
1483
  msgid ""
1484
  "Clears all cache entries related to this site, <i>including other web "
1485
  "applications</i>."
1486
  msgstr ""
1487
 
1488
+ #: admin/tpl/manage/manage_purge.php:83
1489
  msgid "This action should only be used if things are cached incorrectly."
1490
  msgstr ""
1491
 
1492
+ #: admin/tpl/manage/manage_purge.php:87
1493
  msgid "This will clear EVERYTHING inside the cache."
1494
  msgstr ""
1495
 
1496
+ #: admin/tpl/manage/manage_purge.php:88
1497
  msgid "This may cause heavy load on the server."
1498
  msgstr ""
1499
 
1500
+ #: admin/tpl/manage/manage_purge.php:89
1501
  msgid "If only the WordPress site should be purged, use purge all."
1502
  msgstr ""
1503
 
1504
+ #: admin/tpl/manage/manage_purge.php:97 admin/tpl/manage.php:5
1505
  #: admin/tpl/network_settings.php:7 admin/tpl/settings.php:7
1506
  msgid "Purge"
1507
  msgstr ""
1508
 
1509
+ #: admin/tpl/manage/manage_purge.php:130
1510
  msgid "Purge By..."
1511
  msgstr ""
1512
 
1513
+ #: admin/tpl/manage/manage_purge.php:132
1514
  msgid "Select below for \"Purge by\" options."
1515
  msgstr ""
1516
 
1517
+ #: admin/tpl/manage/manage_purge.php:133
1518
  #: admin/tpl/setting/settings_cache.php:73
1519
  #: admin/tpl/setting/settings_cache.php:90
1520
  #: admin/tpl/setting/settings_cdn.php:116
1521
  #: admin/tpl/setting/settings_cdn.php:143
1522
  #: admin/tpl/setting/settings_crawler.php:132
1523
  #: admin/tpl/setting/settings_excludes.php:25
1524
+ #: admin/tpl/setting/settings_excludes.php:43
1525
+ #: admin/tpl/setting/settings_excludes.php:57
1526
+ #: admin/tpl/setting/settings_excludes.php:80
1527
+ #: admin/tpl/setting/settings_excludes.php:118
1528
  #: admin/tpl/setting/settings_inc.cache_object.php:114
1529
  #: admin/tpl/setting/settings_inc.cache_object.php:122
1530
  #: admin/tpl/setting/settings_inc.exclude_cookies.php:19
1538
  msgid "One per line."
1539
  msgstr ""
1540
 
1541
+ #: admin/tpl/manage/manage_purge.php:160
1542
  msgid "Category"
1543
  msgstr ""
1544
 
1545
+ #: admin/tpl/manage/manage_purge.php:166
1546
  msgid "Post ID"
1547
  msgstr ""
1548
 
1549
+ #: admin/tpl/manage/manage_purge.php:172
1550
  msgid "Tag"
1551
  msgstr ""
1552
 
1553
+ #: admin/tpl/manage/manage_purge.php:178
1554
  msgid "URL"
1555
  msgstr ""
1556
 
1557
+ #: admin/tpl/manage/manage_purge.php:184
1558
  msgid ""
1559
  "Purge pages by category name - e.g. %2$s should be used for the URL %1$s."
1560
  msgstr ""
1561
 
1562
+ #: admin/tpl/manage/manage_purge.php:189
1563
  msgid "Purge pages by post ID."
1564
  msgstr ""
1565
 
1566
+ #: admin/tpl/manage/manage_purge.php:193
1567
  msgid "Purge pages by tag name - e.g. %2$s should be used for the URL %1$s."
1568
  msgstr ""
1569
 
1570
+ #: admin/tpl/manage/manage_purge.php:198
1571
  msgid "Purge pages by relative or full URL."
1572
  msgstr ""
1573
 
1574
+ #: admin/tpl/manage/manage_purge.php:199
1575
  msgid "e.g. Use %s or %s."
1576
  msgstr ""
1577
 
1578
+ #: admin/tpl/manage/manage_purge.php:212
1579
  msgid "Purge List"
1580
  msgstr ""
1581
 
1613
  msgid "Media"
1614
  msgstr ""
1615
 
1616
+ #: admin/tpl/network_settings.php:10 admin/tpl/setting/settings_debug.php:78
1617
  #: admin/tpl/settings.php:14
1618
  msgid "Advanced"
1619
  msgstr ""
1822
 
1823
  #: admin/tpl/setting/settings_cache.php:67
1824
  #: admin/tpl/setting/settings_excludes.php:19
1825
+ #: admin/tpl/setting/settings_excludes.php:37
1826
  msgid "The URLs will be compared to the REQUEST_URI server variable."
1827
  msgstr ""
1828
 
1829
  #: admin/tpl/setting/settings_cache.php:68
1830
  #: admin/tpl/setting/settings_excludes.php:20
1831
+ #: admin/tpl/setting/settings_excludes.php:38
1832
  #: admin/tpl/setting/settings_tuning.php:174
1833
  msgid "For example, for %s, %s can be used here."
1834
  msgstr ""
1835
 
1836
  #: admin/tpl/setting/settings_cache.php:71
1837
  #: admin/tpl/setting/settings_excludes.php:23
1838
+ #: admin/tpl/setting/settings_excludes.php:41
1839
  msgid "To match the beginning, add %s to the beginning of the item."
1840
  msgstr ""
1841
 
1842
  #: admin/tpl/setting/settings_cache.php:72
1843
  #: admin/tpl/setting/settings_excludes.php:24
1844
+ #: admin/tpl/setting/settings_excludes.php:42
1845
  msgid "To do an exact match, add %s to the end of the URL."
1846
  msgstr ""
1847
 
1965
  msgstr ""
1966
 
1967
  #: admin/tpl/setting/settings_cdn.php:155
 
1968
  msgid "Off"
1969
  msgstr ""
1970
 
2251
  msgid "Developer Testing"
2252
  msgstr ""
2253
 
2254
+ #: admin/tpl/setting/settings_debug.php:13
2255
+ msgid "Disable All Features"
2256
+ msgstr ""
2257
+
2258
+ #: admin/tpl/setting/settings_debug.php:17
2259
+ msgid ""
2260
+ "This will disable LSCache and all optimization features for debug purpose."
2261
  msgstr ""
2262
 
2263
+ #: admin/tpl/setting/settings_debug.php:41
2264
  msgid "Admin IP only"
2265
  msgstr ""
2266
 
2267
+ #: admin/tpl/setting/settings_debug.php:45
2268
  msgid "Outputs to WordPress debug log."
2269
  msgstr ""
2270
 
2271
+ #: admin/tpl/setting/settings_debug.php:46
2272
  msgid ""
2273
  "This should be set to off once everything is working to prevent filling the "
2274
  "disk."
2275
  msgstr ""
2276
 
2277
+ #: admin/tpl/setting/settings_debug.php:47
2278
  msgid ""
2279
  "The Admin IP option will only output log messages on requests from admin IPs."
2280
  msgstr ""
2281
 
2282
+ #: admin/tpl/setting/settings_debug.php:48
2283
  msgid "The logs will be outputted to %s."
2284
  msgstr ""
2285
 
2286
+ #: admin/tpl/setting/settings_debug.php:54
2287
  msgid "Admin IPs"
2288
  msgstr ""
2289
 
2290
+ #: admin/tpl/setting/settings_debug.php:58
2291
  msgid ""
2292
  "Allows listed IPs (one per line) to perform certain actions from their "
2293
  "browsers."
2294
  msgstr ""
2295
 
2296
+ #: admin/tpl/setting/settings_debug.php:59
2297
  msgid ""
2298
  "More information about the available commands can be found <a %s>here</a>."
2299
  msgstr ""
2300
 
2301
+ #: admin/tpl/setting/settings_debug.php:66
2302
  msgid "Debug Level"
2303
  msgstr ""
2304
 
2305
+ #: admin/tpl/setting/settings_debug.php:72
2306
  msgid "Basic"
2307
  msgstr ""
2308
 
2309
+ #: admin/tpl/setting/settings_debug.php:82
2310
  msgid "Advanced level will log more details."
2311
  msgstr ""
2312
 
2313
+ #: admin/tpl/setting/settings_debug.php:91
2314
  #: admin/tpl/setting/settings_tuning.php:88
2315
  msgid "MB"
2316
  msgstr ""
2317
 
2318
+ #: admin/tpl/setting/settings_debug.php:93
2319
  msgid ""
2320
  "Specify the maximum size of the log file. Minimum is 3MB. Maximum is 3000MB."
2321
  msgstr ""
2322
 
2323
+ #: admin/tpl/setting/settings_debug.php:100
2324
  msgid "Heartbeat"
2325
  msgstr ""
2326
 
2327
+ #: admin/tpl/setting/settings_debug.php:104
2328
  msgid ""
2329
  "Disable WordPress heartbeat to prevent AJAX calls from breaking debug "
2330
  "logging. WARNING: Disabling this may cause WordPress tasks triggered by AJAX "
2331
  "to stop working."
2332
  msgstr ""
2333
 
2334
+ #: admin/tpl/setting/settings_debug.php:110
2335
  msgid "Log Cookies"
2336
  msgstr ""
2337
 
2338
+ #: admin/tpl/setting/settings_debug.php:114
2339
  msgid "Log request cookie values."
2340
  msgstr ""
2341
 
2342
+ #: admin/tpl/setting/settings_debug.php:120
2343
  msgid "Collapse Query Strings"
2344
  msgstr ""
2345
 
2346
+ #: admin/tpl/setting/settings_debug.php:124
2347
  msgid "Shorten query strings in the debug log to improve readability."
2348
  msgstr ""
2349
 
2350
+ #: admin/tpl/setting/settings_debug.php:130
2351
  msgid "Log Filters"
2352
  msgstr ""
2353
 
2354
+ #: admin/tpl/setting/settings_debug.php:134
2355
  msgid ""
2356
  "Log all WordPress filter hooks. WARNING: Enabling this option will cause log "
2357
  "file size to grow quickly."
2358
  msgstr ""
2359
 
2360
+ #: admin/tpl/setting/settings_debug.php:140
2361
  msgid "Exclude Filters"
2362
  msgstr ""
2363
 
2364
+ #: admin/tpl/setting/settings_debug.php:144
2365
  msgid "Listed filters (one per line) will not be logged."
2366
  msgstr ""
2367
 
2368
+ #: admin/tpl/setting/settings_debug.php:145
2369
+ #: admin/tpl/setting/settings_debug.php:156
2370
  msgid "Recommended default value"
2371
  msgstr ""
2372
 
2373
+ #: admin/tpl/setting/settings_debug.php:151
2374
  msgid "Exclude Part Filters"
2375
  msgstr ""
2376
 
2377
+ #: admin/tpl/setting/settings_debug.php:155
2378
  msgid "Filters containing these strings (one per line) will not be logged."
2379
  msgstr ""
2380
 
2446
  msgstr ""
2447
 
2448
  #: admin/tpl/setting/settings_excludes.php:6
2449
+ msgid "Exclude Settings"
2450
  msgstr ""
2451
 
2452
  #: admin/tpl/setting/settings_excludes.php:14
2453
+ msgid "Force Cache URIs"
2454
  msgstr ""
2455
 
2456
  #: admin/tpl/setting/settings_excludes.php:18
2457
+ msgid ""
2458
+ "Paths containing these strings will be cached regardless of no-cacheable "
2459
+ "settings."
2460
  msgstr ""
2461
 
2462
  #: admin/tpl/setting/settings_excludes.php:32
2463
+ msgid "Do Not Cache URIs"
2464
  msgstr ""
2465
 
2466
  #: admin/tpl/setting/settings_excludes.php:36
2467
+ msgid "Paths containing these strings will not be cached."
2468
+ msgstr ""
2469
+
2470
+ #: admin/tpl/setting/settings_excludes.php:50
2471
+ msgid "Do Not Cache Query Strings"
2472
+ msgstr ""
2473
+
2474
+ #: admin/tpl/setting/settings_excludes.php:54
2475
  msgid "Query string containing these parameters will not be cached."
2476
  msgstr ""
2477
 
2478
+ #: admin/tpl/setting/settings_excludes.php:55
2479
  msgid "For example, for %s, %s and %s can be used here."
2480
  msgstr ""
2481
 
2482
+ #: admin/tpl/setting/settings_excludes.php:64
2483
  msgid "Do Not Cache Categories"
2484
  msgstr ""
2485
 
2486
+ #: admin/tpl/setting/settings_excludes.php:77
2487
  msgid "All categories are cached by default."
2488
  msgstr ""
2489
 
2490
+ #: admin/tpl/setting/settings_excludes.php:78
2491
+ #: admin/tpl/setting/settings_excludes.php:116
2492
  #: admin/tpl/setting/settings_inc.exclude_cookies.php:16
2493
  #: admin/tpl/setting/settings_inc.exclude_useragent.php:15
2494
  msgid "To prevent %s from being cached, enter it here."
2495
  msgstr ""
2496
 
2497
+ #: admin/tpl/setting/settings_excludes.php:78
2498
  msgid "categories"
2499
  msgstr ""
2500
 
2501
+ #: admin/tpl/setting/settings_excludes.php:86
2502
  msgid ""
2503
  "If the category slug is not found, the category will be removed from the "
2504
  "list on save."
2505
  msgstr ""
2506
 
2507
+ #: admin/tpl/setting/settings_excludes.php:87
2508
+ #: admin/tpl/setting/settings_excludes.php:125
2509
  msgid "To exclude %1$s, insert %2$s."
2510
  msgstr ""
2511
 
2512
+ #: admin/tpl/setting/settings_excludes.php:95
2513
  msgid "Do Not Cache Tags"
2514
  msgstr ""
2515
 
2516
+ #: admin/tpl/setting/settings_excludes.php:115
2517
  msgid "All tags are cached by default."
2518
  msgstr ""
2519
 
2520
+ #: admin/tpl/setting/settings_excludes.php:116
2521
  msgid "tags"
2522
  msgstr ""
2523
 
2524
+ #: admin/tpl/setting/settings_excludes.php:124
2525
  msgid ""
2526
  "If the tag slug is not found, the tag will be removed from the list on save."
2527
  msgstr ""
2528
 
2529
+ #: admin/tpl/setting/settings_excludes.php:145
2530
  msgid "Do Not Cache Roles"
2531
  msgstr ""
2532
 
2533
+ #: admin/tpl/setting/settings_excludes.php:151
2534
  msgid "Selected roles will be excluded from cache."
2535
  msgstr ""
2536
 
2745
  msgid "Failed"
2746
  msgstr ""
2747
 
 
 
 
 
2748
  #: admin/tpl/setting/settings_inc.cache_object.php:32
2749
  msgid "Use object cache functionality."
2750
  msgstr ""
3690
  msgstr ""
3691
 
3692
  #: inc/gui.class.php:292 includes/litespeed-cache-gui.class.php:292
3693
+ msgid "Forced cacheable"
3694
  msgstr ""
3695
 
3696
  #: inc/gui.class.php:299 includes/litespeed-cache-gui.class.php:299
3697
+ msgid "Non cacheable"
3698
  msgstr ""
3699
 
3700
  #: inc/gui.class.php:306 includes/litespeed-cache-gui.class.php:306
3701
+ msgid "Private cache"
3702
  msgstr ""
3703
 
3704
  #: inc/gui.class.php:313 includes/litespeed-cache-gui.class.php:313
3705
+ msgid "No optimization"
3706
  msgstr ""
3707
 
3708
+ #: inc/gui.class.php:320 includes/litespeed-cache-gui.class.php:320
3709
+ msgid "More settings"
3710
  msgstr ""
3711
 
3712
+ #: inc/gui.class.php:340 includes/litespeed-cache-gui.class.php:340
3713
+ msgid "LiteSpeed Cache Purge All"
3714
  msgstr ""
3715
 
3716
+ #: inc/gui.class.php:390 includes/litespeed-cache-gui.class.php:390
3717
+ msgid "LSCache"
3718
  msgstr ""
3719
 
3720
  #: inc/img_optm.class.php:80
3788
  msgid "Imported setting file %s successfully."
3789
  msgstr ""
3790
 
3791
+ #: inc/litespeed-cache.class.php:267 includes/litespeed-cache.class.php:267
3792
  msgid "Crawler blacklist is saved."
3793
  msgstr ""
3794
 
3795
+ #: inc/litespeed-cache.class.php:278 includes/litespeed-cache.class.php:278
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3796
  msgid "Notified LiteSpeed Web Server to purge everything."
3797
  msgstr ""
3798
 
3799
+ #: inc/litespeed-cache.class.php:288 includes/litespeed-cache.class.php:288
3800
  msgid "Notified LiteSpeed Web Server to purge the list."
3801
  msgstr ""
3802
 
3828
  msgid "Original saved %s"
3829
  msgstr ""
3830
 
3831
+ #: inc/purge.class.php:116 includes/litespeed-cache-purge.class.php:116
3832
+ msgid "Purge all caches successfully."
3833
+ msgstr ""
3834
+
3835
+ #: inc/purge.class.php:139 includes/litespeed-cache-purge.class.php:139
3836
+ msgid "Notified LiteSpeed Web Server to purge all LSCache entries."
3837
+ msgstr ""
3838
+
3839
+ #: inc/purge.class.php:158 includes/litespeed-cache-purge.class.php:158
3840
+ msgid "Notified LiteSpeed Web Server to purge CSS/JS entries."
3841
+ msgstr ""
3842
+
3843
+ #: inc/purge.class.php:175 includes/litespeed-cache-purge.class.php:175
3844
  msgid "Opcode cache is not enabled."
3845
  msgstr ""
3846
 
3847
+ #: inc/purge.class.php:187 includes/litespeed-cache-purge.class.php:187
3848
  msgid "Reset the entire opcode cache successfully."
3849
  msgstr ""
3850
 
3851
+ #: inc/purge.class.php:206 includes/litespeed-cache-purge.class.php:206
3852
  msgid "Object cache is not enabled."
3853
  msgstr ""
3854
 
3855
+ #: inc/purge.class.php:216 includes/litespeed-cache-purge.class.php:216
3856
  msgid "Purge all object caches successfully."
3857
  msgstr ""
3858
 
3859
+ #: inc/purge.class.php:368 includes/litespeed-cache-purge.class.php:368
3860
+ msgid "Notified LiteSpeed Web Server to purge the front page."
3861
+ msgstr ""
3862
+
3863
+ #: inc/purge.class.php:382 includes/litespeed-cache-purge.class.php:382
3864
+ msgid "Notified LiteSpeed Web Server to purge pages."
3865
+ msgstr ""
3866
+
3867
+ #: inc/purge.class.php:402 includes/litespeed-cache-purge.class.php:402
3868
+ msgid "Notified LiteSpeed Web Server to purge error pages."
3869
+ msgstr ""
3870
+
3871
+ #: inc/purge.class.php:430 includes/litespeed-cache-purge.class.php:430
3872
  msgid "Purge category %s"
3873
  msgstr ""
3874
 
3875
+ #: inc/purge.class.php:457 includes/litespeed-cache-purge.class.php:457
3876
  msgid "Purge Post ID %s"
3877
  msgstr ""
3878
 
3879
+ #: inc/purge.class.php:486 includes/litespeed-cache-purge.class.php:486
3880
  msgid "Purge tag %s"
3881
  msgstr ""
3882
 
3883
+ #: inc/purge.class.php:520 includes/litespeed-cache-purge.class.php:520
3884
  msgid "Purge url %s"
3885
  msgstr ""
3886
 
litespeed-cache.php CHANGED
@@ -15,7 +15,7 @@
15
  * Plugin Name: LiteSpeed Cache
16
  * Plugin URI: https://www.litespeedtech.com/products/cache-plugins/wordpress-acceleration
17
  * Description: WordPress plugin to connect to LSCache on LiteSpeed Web Server.
18
- * Version: 2.1.2
19
  * Author: LiteSpeed Technologies
20
  * Author URI: https://www.litespeedtech.com
21
  * License: GPLv3
15
  * Plugin Name: LiteSpeed Cache
16
  * Plugin URI: https://www.litespeedtech.com/products/cache-plugins/wordpress-acceleration
17
  * Description: WordPress plugin to connect to LSCache on LiteSpeed Web Server.
18
+ * Version: 2.2
19
  * Author: LiteSpeed Technologies
20
  * Author URI: https://www.litespeedtech.com
21
  * License: GPLv3
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: LiteSpeedTech
3
  Tags: cache, wp-cache, litespeed, super cache, http2, total cache, optimize, object cache, redis, memcached, lazy load, database cleaner
4
  Requires at least: 4.0
5
  Tested up to: 4.9.4
6
- Stable tag: 2.1.2
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl.html
9
 
@@ -16,9 +16,9 @@ LiteSpeed Cache for WordPress (LSCWP) is an all-in-one site acceleration plugin,
16
  LSCWP supports WordPress Multisite and is compatible with most popular plugins, including WooCommerce, bbPress, and Yoast SEO.
17
 
18
  == Requirements ==
19
- **General Features** may be used by anyone with any web server.
20
 
21
- **LiteSpeed Exclusive Features** require the use of [OpenLiteSpeed](http://openlitespeed.org) (free, open source) or [LiteSpeed Web Server Enterprise](https://www.litespeedtech.com/products/litespeed-web-server) with cache module installed.
22
 
23
  == Plugin Features ==
24
 
@@ -252,13 +252,23 @@ Click on the `Advanced View` link at the top of the page, and several more tabs
252
 
253
  == Changelog ==
254
 
 
 
 
 
 
 
 
 
 
 
255
  = 2.1.2 - Mar 28 2018 =
256
- * [NEW] <strong>Image Optimization</strong> Clean Up Unfinished Data feature.
257
  * [IAPI] IAPI v2.1.2.
258
  * [IMPROVEMENT] <strong>CSS/JS Minify</strong> Reduced loading time significantly by improving CSS/JS minify loading process. (@kokers)
259
  * [IMPROVEMENT] <strong>CSS/JS Minify</strong> Cache empty JS Minify content. (@kokers)
260
  * [IMPROVEMENT] <strong>Cache</strong> Cache 301 redirect when scheme/host are same.
261
- * [BUGFIX] <strong>Media</strong> Lazy load now can support webp. (@relle)
262
  * [UPDATE] <strong>CSS/JS Optimize</strong> Serve static files for CSS async & lazy load JS library.
263
  * [UPDATE] <strong>Report</strong> Appended Basic/Advanced View setting to Report.
264
  * [UPDATE] <strong>CSS/JS Minify</strong> Removed zero-width space from CSS/JS content.
@@ -269,16 +279,16 @@ Click on the `Advanced View` link at the top of the page, and several more tabs
269
  * [BUGFIX] Fixed issue where 304 header was blank on feed page refresh.
270
 
271
  = 2.1.1 - Mar 20 2018 =
272
- * [NEW] <strong>Browser Cache</strong> Unlocked for non-LiteSpeed users.
273
  * [IMPROVEMENT] <strong>Image Optimization</strong> Fixed issue where images with bad postmeta value continued to show in not-yet-requested queue.
274
 
275
  = 2.1 - Mar 15 2018 =
276
- * [NEW] <strong>Image Optimization</strong> Unlocked for non-LiteSpeed users.
277
- * [NEW] <strong>Object Cache</strong> Unlocked for non-LiteSpeed users.
278
- * [NEW] <strong>Crawler</strong> Unlocked for non-LiteSpeed users.
279
- * [NEW] <strong>Database Cleaner and Optimizer</strong> Unlocked for non-LiteSpeed users.
280
- * [NEW] <strong>Lazy Load Images</strong> Unlocked for non-LiteSpeed users.
281
- * [NEW] <strong>CSS/JS/HTML Minify/Combine Optimize</strong> Unlocked for non-LiteSpeed users.
282
  * [IAPI] IAPI v2.0.
283
  * [IAPI] Increased max rows prefetch when client has additional credit.
284
  * [IMPROVEMENT] <strong>CDN</strong> Multiple domains may now be used.
@@ -290,7 +300,7 @@ Click on the `Advanced View` link at the top of the page, and several more tabs
290
  * [INTEGRATION] CDN compatibility with WPML multiple domains. (@egemensarica)
291
 
292
  = 2.0 - Mar 7 2018 =
293
- * [NEW] <strong>Image Optimization</strong> Added level up guidance.
294
  * [REFACTOR] <strong>Image Optimization</strong> Refactored Image Optimization class.
295
  * [IAPI] <strong>Image Optimization</strong> New European Image Optimization server (EU2).
296
  * [IMPROVEMENT] <strong>Image Optimization</strong> Manual pull action continues pulling until complete.
@@ -314,15 +324,15 @@ Click on the `Advanced View` link at the top of the page, and several more tabs
314
  * [Hotfix] Removed empty crawler when no role simulation is set.
315
 
316
  = 1.9.1 - February 20 2018 =
317
- * [NEW] Role Simulation crawler.
318
- * [NEW] WebP multiple crawler.
319
- * [NEW] HTTP/2 support for crawler.
320
  * [BUGFIX] Fixed a js bug with the auto complete mobile user agents field when cache mobile is turned on.
321
  * [BUGFIX] Fixed a constant undefined warning after activation.
322
  * [GUI] Sitemap generation settings are no longer hidden when using a custom sitemap.
323
 
324
  = 1.9 - February 12 2018 =
325
- * [NEW] Inline CSS/JS Minify.
326
  * [IMPROVEMENT] Removed Composer vendor to thin the plugin folder.
327
  * [UPDATE] Tweaked H2 to H1 in Admin headings for accessibility. (@steverep)
328
  * [GUI] Added Mobile User Agents to basic view.
3
  Tags: cache, wp-cache, litespeed, super cache, http2, total cache, optimize, object cache, redis, memcached, lazy load, database cleaner
4
  Requires at least: 4.0
5
  Tested up to: 4.9.4
6
+ Stable tag: 2.2
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl.html
9
 
16
  LSCWP supports WordPress Multisite and is compatible with most popular plugins, including WooCommerce, bbPress, and Yoast SEO.
17
 
18
  == Requirements ==
19
+ **General Features** may be used by anyone with any web server (LiteSpeed, Apache, NGiNX, etc.).
20
 
21
+ **LiteSpeed Exclusive Features** require OpenLiteSpeed, commercial LiteSpeed products, or LiteSpeed-powered hosting.
22
 
23
  == Plugin Features ==
24
 
252
 
253
  == Changelog ==
254
 
255
+ = 2.2 - Apr 2 2018 =
256
+ * [NEW FEATURE] <strong>Debug</strong> Disable All Features setting in Debug tab. (@monarobase)
257
+ * [NEW FEATURE] <strong>Cache</strong> Force Cacheable URIs setting in Excludes tab.
258
+ * [NEW FEATURE] <strong>Purge</strong> Purge all LSCache and other caches in one link.
259
+ * [REFACTOR] <strong>Purge</strong> Refactored Purge class.
260
+ * [BUGFIX] Query strings in DoNotCacheURI setting now works.
261
+ * [BUGFIX] <strong>Cache</strong> Mobile cache compatibility with WebP vary. (@Shivam #987121)
262
+ * [UPDATE] <strong>Purge</strong> Moved purge_all to Purge class from core class.
263
+ * [API] Set cacheable/Set force cacheable. (@Jacob)
264
+
265
  = 2.1.2 - Mar 28 2018 =
266
+ * [NEW FEATURE] <strong>Image Optimization</strong> Clean Up Unfinished Data feature.
267
  * [IAPI] IAPI v2.1.2.
268
  * [IMPROVEMENT] <strong>CSS/JS Minify</strong> Reduced loading time significantly by improving CSS/JS minify loading process. (@kokers)
269
  * [IMPROVEMENT] <strong>CSS/JS Minify</strong> Cache empty JS Minify content. (@kokers)
270
  * [IMPROVEMENT] <strong>Cache</strong> Cache 301 redirect when scheme/host are same.
271
+ * [BUGFIX] <strong>Media</strong> Lazy load now can support WebP. (@relle)
272
  * [UPDATE] <strong>CSS/JS Optimize</strong> Serve static files for CSS async & lazy load JS library.
273
  * [UPDATE] <strong>Report</strong> Appended Basic/Advanced View setting to Report.
274
  * [UPDATE] <strong>CSS/JS Minify</strong> Removed zero-width space from CSS/JS content.
279
  * [BUGFIX] Fixed issue where 304 header was blank on feed page refresh.
280
 
281
  = 2.1.1 - Mar 20 2018 =
282
+ * [NEW FEATURE] <strong>Browser Cache</strong> Unlocked for non-LiteSpeed users.
283
  * [IMPROVEMENT] <strong>Image Optimization</strong> Fixed issue where images with bad postmeta value continued to show in not-yet-requested queue.
284
 
285
  = 2.1 - Mar 15 2018 =
286
+ * [NEW FEATURE] <strong>Image Optimization</strong> Unlocked for non-LiteSpeed users.
287
+ * [NEW FEATURE] <strong>Object Cache</strong> Unlocked for non-LiteSpeed users.
288
+ * [NEW FEATURE] <strong>Crawler</strong> Unlocked for non-LiteSpeed users.
289
+ * [NEW FEATURE] <strong>Database Cleaner and Optimizer</strong> Unlocked for non-LiteSpeed users.
290
+ * [NEW FEATURE] <strong>Lazy Load Images</strong> Unlocked for non-LiteSpeed users.
291
+ * [NEW FEATURE] <strong>CSS/JS/HTML Minify/Combine Optimize</strong> Unlocked for non-LiteSpeed users.
292
  * [IAPI] IAPI v2.0.
293
  * [IAPI] Increased max rows prefetch when client has additional credit.
294
  * [IMPROVEMENT] <strong>CDN</strong> Multiple domains may now be used.
300
  * [INTEGRATION] CDN compatibility with WPML multiple domains. (@egemensarica)
301
 
302
  = 2.0 - Mar 7 2018 =
303
+ * [NEW FEATURE] <strong>Image Optimization</strong> Added level up guidance.
304
  * [REFACTOR] <strong>Image Optimization</strong> Refactored Image Optimization class.
305
  * [IAPI] <strong>Image Optimization</strong> New European Image Optimization server (EU2).
306
  * [IMPROVEMENT] <strong>Image Optimization</strong> Manual pull action continues pulling until complete.
324
  * [Hotfix] Removed empty crawler when no role simulation is set.
325
 
326
  = 1.9.1 - February 20 2018 =
327
+ * [NEW FEATURE] Role Simulation crawler.
328
+ * [NEW FEATURE] WebP multiple crawler.
329
+ * [NEW FEATURE] HTTP/2 support for crawler.
330
  * [BUGFIX] Fixed a js bug with the auto complete mobile user agents field when cache mobile is turned on.
331
  * [BUGFIX] Fixed a constant undefined warning after activation.
332
  * [GUI] Sitemap generation settings are no longer hidden when using a custom sitemap.
333
 
334
  = 1.9 - February 12 2018 =
335
+ * [NEW FEATURE] Inline CSS/JS Minify.
336
  * [IMPROVEMENT] Removed Composer vendor to thin the plugin folder.
337
  * [UPDATE] Tweaked H2 to H1 in Admin headings for accessibility. (@steverep)
338
  * [GUI] Added Mobile User Agents to basic view.