PluginProbe
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript / 4.1.16
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript v4.1.16
4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.0.30 4.0.29 4.0.28 4.0.27 4.0.26 4.0.24 4.0.25 4.0.23 4.0.22 4.0.21 4.0.19 4.0.18 4.0.17 4.0.16 1.9.3 1.9.4 1.9.5 1.9.6 All 170 releases
← All changes | advanced-cache.php +11 -52 1.9.34.1.16 View file →
@@ -2,63 +2,22 @@
2 2 /**
3 3 * BerqWP Advanced Cache Drop-in
4 4 */
5 5
6 -if (!defined('ABSPATH')) exit;
6 +// ABSPATH is not yet defined when this dropin runs — do not exit here
7 7
8 -require_once ABSPATH . '/wp-content/plugins/searchpro/inc/class-ignoreparams.php';
9 -require_once ABSPATH . '/wp-content/plugins/searchpro/inc/dropin-functions.php';
8 +if (!defined('optifer_PATH')) {
9 + define('optifer_PATH', WP_CONTENT_DIR . '/plugins/searchpro/');
10 +}
10 11
11 -if ($_SERVER['REQUEST_METHOD'] !== 'POST' && !bwp_is_user_logged_in() && !bwp_is_ajax()) {
12 - $slug = $_SERVER['REQUEST_URI'];
13 - $slug = dropin_remove_ignore_params($slug);
14 - $cache_key = md5($slug);
15 - $cache_directory = ABSPATH . '/wp-content/cache/berqwp/html/';
16 - $cache_file = $cache_directory . $cache_key . '.html';
17 - $gzip_support = function_exists('gzencode') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false;
18 - $cache_max_life = @filemtime($cache_file) + (18 * 60 * 60);
19 - $is_litespeed = isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false;
20 -
21 - if (file_exists($cache_file) && $cache_max_life > time()) {
22 - if ($gzip_support && file_exists($cache_directory . $cache_key . '.gz') && !$is_litespeed) {
23 - $cache_file = $cache_directory . $cache_key . '.gz';
24 - header('Content-Encoding: gzip');
25 - header('Content-Type: text/html; charset=UTF-8');
26 - }
12 +if (is_dir(optifer_PATH)) {
13 + require_once WP_CONTENT_DIR . '/plugins/searchpro/inc/crawler/berqDetectCrawler.php';
14 + require_once WP_CONTENT_DIR . '/plugins/searchpro/inc/cache/class-ignoreparams.php';
15 + require_once WP_CONTENT_DIR . '/plugins/searchpro/inc/dropin-functions.php';
16 + require_once WP_CONTENT_DIR . '/plugins/searchpro/inc/class-berqconfigs.php';
17 + require_once WP_CONTENT_DIR . '/plugins/searchpro/inc/common-functions.php';
27 18
28 -
29 - if (!isset($_GET['creating_cache']) && file_exists($cache_file)) {
30 - $lastModified = filemtime($cache_file);
31 - $etag = md5_file($cache_file);
32 - header('ETag: ' . $etag);
33 - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $lastModified) . ' GMT');
34 -
35 - // Check if the client has a cached copy and if it's still valid using Last-Modified
36 - if ((isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $lastModified) || (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] === $etag)) {
37 - // The client's cache is still valid based on Last-Modified, respond with a 304 Not Modified
38 - header('HTTP/1.1 304 Not Modified');
39 - header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
40 - header('Cache-Control: no-cache, must-revalidate');
41 - exit();
42 -
43 - }
19 + bwp_serve_advanced_cache('dropin');
44 20
45 - header('Cache-Control: public, max-age=86400');
46 -
47 - if (file_exists($cache_file)) {
48 - readfile($cache_file);
49 - exit();
50 - }
51 - }
52 21
53 - }
54 -
55 22 }
56 23
57 -// add_action('wp', function () {
58 -// if (class_exists('berqCache') && !is_admin()) {
59 -// global $berqwp_is_dropin;
60 -// $berqwp_is_dropin = true;
61 -// $berqCache = new berqCache();
62 -// $berqCache->html_cache();
63 -// }
64 -// });