Version Description
Download this release
Release Info
Developer | donncha |
Plugin | WP Super Cache |
Version | 0.8.5 |
Comparing to | |
See all releases |
Code changes from version 0.8.4 to 0.8.5
- Changelog.txt +86 -0
- readme.txt +8 -4
- wp-cache-phase1.php +11 -6
- wp-cache-phase2.php +42 -14
- wp-cache.php +58 -21
Changelog.txt
CHANGED
@@ -1,3 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
2008-10-22 15:55 donncha
|
2 |
|
3 |
* readme.txt, wp-cache.php: Bump version number to 0.8.4
|
1 |
+
2008-11-25 12:58 donncha
|
2 |
+
|
3 |
+
* readme.txt, wp-cache.php: Bump version number to 0.8.5
|
4 |
+
|
5 |
+
2008-11-25 12:45 donncha
|
6 |
+
|
7 |
+
* wp-cache-phase2.php: Added "supercache_dir" filter so supercache
|
8 |
+
directory can be modified.
|
9 |
+
|
10 |
+
2008-11-25 12:40 donncha
|
11 |
+
|
12 |
+
* wp-cache-phase2.php: Removed backslashes from the supercache
|
13 |
+
filename
|
14 |
+
|
15 |
+
2008-11-25 12:27 donncha
|
16 |
+
|
17 |
+
* wp-cache.php: Warn if Apache modules are missing.
|
18 |
+
Display gzip cache rewrite rules.
|
19 |
+
Deal with WordPress MU better as it can't upgrade the .htaccess
|
20 |
+
file.
|
21 |
+
|
22 |
+
2008-11-25 12:24 donncha
|
23 |
+
|
24 |
+
* wp-cache-phase1.php: Added wp_cache_key cacheaction to modify
|
25 |
+
cache key (ie. add user agent, IP, etc)
|
26 |
+
|
27 |
+
2008-11-25 11:10 donncha
|
28 |
+
|
29 |
+
* wp-cache-phase1.php, wp-cache-phase2.php: Check that cache file
|
30 |
+
exists before serving, it may have been removed without the meta
|
31 |
+
file
|
32 |
+
|
33 |
+
2008-11-25 11:01 donncha
|
34 |
+
|
35 |
+
* wp-cache-phase2.php: Removed $gzipped variable
|
36 |
+
|
37 |
+
2008-11-25 10:54 donncha
|
38 |
+
|
39 |
+
* wp-cache-phase2.php: No need to addslashes() to file functions
|
40 |
+
|
41 |
+
2008-11-14 13:20 donncha
|
42 |
+
|
43 |
+
* wp-cache-phase2.php: Added wpsupercache_buffer filter so buffer
|
44 |
+
can be manipulated before writing to cache file
|
45 |
+
|
46 |
+
2008-11-14 13:00 donncha
|
47 |
+
|
48 |
+
* wp-cache-phase2.php: Move gzip header detection down
|
49 |
+
|
50 |
+
2008-11-14 10:09 donncha
|
51 |
+
|
52 |
+
* wp-cache-phase1.php, wp-cache-phase2.php: Add gzip headers back
|
53 |
+
if they are missing. Should fix problems with users seeing
|
54 |
+
corrupted pages.
|
55 |
+
|
56 |
+
2008-11-14 10:00 donncha
|
57 |
+
|
58 |
+
* readme.txt: Updated docs on file locking
|
59 |
+
|
60 |
+
2008-11-11 17:28 donncha
|
61 |
+
|
62 |
+
* wp-cache-phase2.php: Write wp-cache php cache files to temporary
|
63 |
+
files before moving into place.
|
64 |
+
Increase gzip compression to 3
|
65 |
+
If cron job failed to get mutex lock, try again in 10 minutes
|
66 |
+
|
67 |
+
2008-11-07 09:43 donncha
|
68 |
+
|
69 |
+
* wp-cache.php: Use WP_CONTENT_URL in mod_rewrite rules.
|
70 |
+
Use WP_CONTENT_DIR in WPCACHEHOME definition.
|
71 |
+
|
72 |
+
2008-10-27 13:21 donncha
|
73 |
+
|
74 |
+
* readme.txt: Added links section and link to WP Widget Cache,
|
75 |
+
props to Ben @ http://www.binarymoon.co.uk/
|
76 |
+
Minor troubleshooting update
|
77 |
+
|
78 |
+
2008-10-23 08:14 donncha
|
79 |
+
|
80 |
+
* wp-cache.php: wp_cache_check_global_config() fixes by joelhardi,
|
81 |
+
http://wordpress.org/support/topic/211477?replies=1#post-879591
|
82 |
+
|
83 |
+
2008-10-22 15:57 donncha
|
84 |
+
|
85 |
+
* Changelog.txt: Updated changelog
|
86 |
+
|
87 |
2008-10-22 15:55 donncha
|
88 |
|
89 |
* readme.txt, wp-cache.php: Bump version number to 0.8.4
|
readme.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Contributors: donncha
|
3 |
Tags: performance,caching,wp-cache
|
4 |
Tested up to: 2.6.2
|
5 |
-
Stable tag: 0.8.
|
6 |
Requires at least: 2.2
|
7 |
|
8 |
A very fast caching engine for WordPress that produces static html files.
|
@@ -88,7 +88,7 @@ This plugin is based on the excellent WP-Cache plugin and therefore brings all t
|
|
88 |
|
89 |
= Will comments and other dynamic parts of my blog update immediately? =
|
90 |
|
91 |
-
Comments will show as soon as they are moderated, depending on the comment policy of the blog owner. Other dynamic elements on a page may not update unless they are written in Javascript, Flash, Java or another client side browser language. The plugin really produces static html pages. No PHP is executed when those pages are served. "Popularity Contest" is one such plugin that will not work.
|
92 |
|
93 |
= Will the Super Cache compression slow down my server? =
|
94 |
|
@@ -122,9 +122,10 @@ If you can't do that, then copy the file. That will work too.
|
|
122 |
8. Anything in your php error_log?
|
123 |
9. If your browser keeps asking you to save the file after the super cache is installed you must disable Super Cache compression. Go to the Settings->WP Super Cache page and disable it there.
|
124 |
10. The plugin does not work very well when PHP's safe mode is active. This must be disabled by your administrator.
|
125 |
-
11. If pages are randomly super cached and sometimes not, your blog can probably be viewed with and without the "www" prefix on the URL. You should choose one way and install the [Enforce www preference](http://txfx.net/code/wordpress/enforce-www-preference/) plugin.
|
126 |
12. Private Server users at Dreamhost should edit wp-content/wp-cache-config.php and set the cache dir to "/tmp/" if they are getting errors about increasing CPU usage. See this [discussion](http://wordpress.org/support/topic/145895?replies=42) for more.
|
127 |
-
13.
|
|
|
128 |
|
129 |
== Custom Caching ==
|
130 |
It is now possible to hook into the caching process using the add_cacheaction() function.
|
@@ -141,6 +142,9 @@ The output of WP-Cache's wp_cache_get_cookies_values() function.
|
|
141 |
|
142 |
See plugins/searchengine.php as an example I use for my [No Adverts for Friends](plugin at http://ocaoimh.ie/no-adverts-for-friends/)
|
143 |
|
|
|
|
|
|
|
144 |
== Updates ==
|
145 |
Updates to the plugin will be posted here, to [Holy Shmoly!](http://ocaoimh.ie/) and the [WP Super Cache homepage](http://ocaoimh.ie/wp-super-cache/) will always link to the newest version.
|
146 |
|
2 |
Contributors: donncha
|
3 |
Tags: performance,caching,wp-cache
|
4 |
Tested up to: 2.6.2
|
5 |
+
Stable tag: 0.8.5
|
6 |
Requires at least: 2.2
|
7 |
|
8 |
A very fast caching engine for WordPress that produces static html files.
|
88 |
|
89 |
= Will comments and other dynamic parts of my blog update immediately? =
|
90 |
|
91 |
+
Comments will show as soon as they are moderated, depending on the comment policy of the blog owner. Other dynamic elements on a page may not update unless they are written in Javascript, Flash, Java or another client side browser language. The plugin really produces static html pages. No PHP is executed when those pages are served. "Popularity Contest" is one such plugin that will not work. Plugins that show different content for mobile users will probaby not work either.
|
92 |
|
93 |
= Will the Super Cache compression slow down my server? =
|
94 |
|
122 |
8. Anything in your php error_log?
|
123 |
9. If your browser keeps asking you to save the file after the super cache is installed you must disable Super Cache compression. Go to the Settings->WP Super Cache page and disable it there.
|
124 |
10. The plugin does not work very well when PHP's safe mode is active. This must be disabled by your administrator.
|
125 |
+
11. If pages are randomly super cached and sometimes not, your blog can probably be viewed with and without the "www" prefix on the URL. You should choose one way and install the [Enforce www preference](http://txfx.net/code/wordpress/enforce-www-preference/) plugin if you are using an old WordPress install. The latest versions redirect themselves (you should always be running the latest version of WordPress anyway!)
|
126 |
12. Private Server users at Dreamhost should edit wp-content/wp-cache-config.php and set the cache dir to "/tmp/" if they are getting errors about increasing CPU usage. See this [discussion](http://wordpress.org/support/topic/145895?replies=42) for more.
|
127 |
+
13. File locking errors such as "failed to acquire key 0x152b: Permission denied in..." or "Page not cached by WP Super Cache. Could not get mutex lock." are a sign that you may have to use file locking. Edit wp-content/wp-cache-config.php and uncomment "$use_flock = true" or set $sem_id to a different value.
|
128 |
+
14. Make sure cache/wp_cache_mutex.lock is writeable by the web server.
|
129 |
|
130 |
== Custom Caching ==
|
131 |
It is now possible to hook into the caching process using the add_cacheaction() function.
|
142 |
|
143 |
See plugins/searchengine.php as an example I use for my [No Adverts for Friends](plugin at http://ocaoimh.ie/no-adverts-for-friends/)
|
144 |
|
145 |
+
== Links ==
|
146 |
+
[WP Widget Cache](http://wordpress.org/extend/plugins/wp-widget-cache/) is another caching plugin for WordPress. This plugin caches the output of widgets and may significantly speed up dynamic page generation times.
|
147 |
+
|
148 |
== Updates ==
|
149 |
Updates to the plugin will be posted here, to [Holy Shmoly!](http://ocaoimh.ie/) and the [WP Super Cache homepage](http://ocaoimh.ie/wp-super-cache/) will always link to the newest version.
|
150 |
|
wp-cache-phase1.php
CHANGED
@@ -37,6 +37,9 @@ $cache_filename = '';
|
|
37 |
$meta_file = '';
|
38 |
$wp_cache_gzip_encoding = '';
|
39 |
|
|
|
|
|
|
|
40 |
function gzip_accepted(){
|
41 |
if( ini_get( 'zlib.output_compression' ) ) // don't compress WP-Cache data files when PHP is already doing it
|
42 |
return false;
|
@@ -49,7 +52,7 @@ if ($cache_compression) {
|
|
49 |
$wp_cache_gzip_encoding = gzip_accepted();
|
50 |
}
|
51 |
|
52 |
-
$key = $blogcacheid . md5($_SERVER['HTTP_HOST'].preg_replace('/#.*$/', '', str_replace( '/index.php', '/', $_SERVER['REQUEST_URI'] ) ).$wp_cache_gzip_encoding.wp_cache_get_cookies_values());
|
53 |
|
54 |
$cache_filename = $file_prefix . $key . '.html';
|
55 |
$meta_file = $file_prefix . $key . '.meta';
|
@@ -57,11 +60,17 @@ $cache_file = realpath( $cache_path . $cache_filename );
|
|
57 |
$meta_pathname = realpath( $cache_path . 'meta/' . $meta_file );
|
58 |
|
59 |
$wp_start_time = microtime();
|
60 |
-
if( ($mtime = @filemtime($meta_pathname)) ) {
|
61 |
if ($mtime + $cache_max_time > time() ) {
|
62 |
$meta = new CacheMeta;
|
63 |
if (! ($meta = unserialize(@file_get_contents($meta_pathname))) )
|
64 |
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
foreach ($meta->headers as $header) {
|
66 |
// godaddy fix, via http://blog.gneu.org/2008/05/wp-supercache-on-godaddy/ and http://www.littleredrails.com/blog/2007/09/08/using-wp-cache-on-godaddy-500-error/
|
67 |
if( strpos( $header, 'Last-Modified:' ) === false )
|
@@ -72,10 +81,6 @@ if( ($mtime = @filemtime($meta_pathname)) ) {
|
|
72 |
if ($meta->dynamic) {
|
73 |
include($cache_file);
|
74 |
} else {
|
75 |
-
/* No used to avoid problems with some PHP installations
|
76 |
-
$content_size += strlen($log);
|
77 |
-
header("Content-Length: $content_size");
|
78 |
-
*/
|
79 |
if(!@readfile ($cache_file))
|
80 |
return;
|
81 |
}
|
37 |
$meta_file = '';
|
38 |
$wp_cache_gzip_encoding = '';
|
39 |
|
40 |
+
$gzipped = 0;
|
41 |
+
$gzsize = 0;
|
42 |
+
|
43 |
function gzip_accepted(){
|
44 |
if( ini_get( 'zlib.output_compression' ) ) // don't compress WP-Cache data files when PHP is already doing it
|
45 |
return false;
|
52 |
$wp_cache_gzip_encoding = gzip_accepted();
|
53 |
}
|
54 |
|
55 |
+
$key = $blogcacheid . md5( do_cacheaction( 'wp_cache_key', $_SERVER['HTTP_HOST'].preg_replace('/#.*$/', '', str_replace( '/index.php', '/', $_SERVER['REQUEST_URI'] ) ).$wp_cache_gzip_encoding.wp_cache_get_cookies_values() ) );
|
56 |
|
57 |
$cache_filename = $file_prefix . $key . '.html';
|
58 |
$meta_file = $file_prefix . $key . '.meta';
|
60 |
$meta_pathname = realpath( $cache_path . 'meta/' . $meta_file );
|
61 |
|
62 |
$wp_start_time = microtime();
|
63 |
+
if( file_exists( $cache_file ) && ($mtime = @filemtime($meta_pathname)) ) {
|
64 |
if ($mtime + $cache_max_time > time() ) {
|
65 |
$meta = new CacheMeta;
|
66 |
if (! ($meta = unserialize(@file_get_contents($meta_pathname))) )
|
67 |
return;
|
68 |
+
// Sometimes the gzip headers are lost. If this is a gzip capable client, send those headers.
|
69 |
+
if( $wp_cache_gzip_encoding && !in_array( 'Content-Encoding: ' . $wp_cache_gzip_encoding, $meta->headers ) ) {
|
70 |
+
array_push($meta, 'Content-Encoding: ' . $wp_cache_gzip_encoding);
|
71 |
+
array_push($meta, 'Vary: Accept-Encoding, Cookie');
|
72 |
+
array_push($meta, 'Content-Length: ' . filesize( $cache_file ) );
|
73 |
+
}
|
74 |
foreach ($meta->headers as $header) {
|
75 |
// godaddy fix, via http://blog.gneu.org/2008/05/wp-supercache-on-godaddy/ and http://www.littleredrails.com/blog/2007/09/08/using-wp-cache-on-godaddy-500-error/
|
76 |
if( strpos( $header, 'Last-Modified:' ) === false )
|
81 |
if ($meta->dynamic) {
|
82 |
include($cache_file);
|
83 |
} else {
|
|
|
|
|
|
|
|
|
84 |
if(!@readfile ($cache_file))
|
85 |
return;
|
86 |
}
|
wp-cache-phase2.php
CHANGED
@@ -27,11 +27,12 @@ function wp_cache_phase2() {
|
|
27 |
if( $_SERVER["REQUEST_METHOD"] == 'POST' || get_option('gzipcompression'))
|
28 |
return;
|
29 |
$script = basename($_SERVER['PHP_SELF']);
|
30 |
-
if (!in_array($script, $cache_acceptable_files) &&
|
31 |
-
wp_cache_is_rejected($_SERVER["REQUEST_URI"]))
|
32 |
return;
|
33 |
if (wp_cache_user_agent_is_rejected()) return;
|
34 |
-
$wp_cache_meta_object
|
|
|
|
|
35 |
if($wp_cache_gzip_encoding)
|
36 |
header('Vary: Accept-Encoding, Cookie');
|
37 |
else
|
@@ -150,7 +151,9 @@ function wp_cache_writers_exit() {
|
|
150 |
function get_current_url_supercache_dir() {
|
151 |
global $cached_direct_pages, $cache_path;
|
152 |
$uri = preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', str_replace( '/index.php', '/', str_replace( '..', '', preg_replace("/(\?.*)?$/", '', $_SERVER['REQUEST_URI'] ) ) ) );
|
|
|
153 |
$dir = strtolower(preg_replace('/:.*$/', '', $_SERVER["HTTP_HOST"])) . $uri; // To avoid XSS attacs
|
|
|
154 |
$dir = trailingslashit( $cache_path . 'supercache/' . $dir );
|
155 |
if( is_array( $cached_direct_pages ) && in_array( $_SERVER[ 'REQUEST_URI' ], $cached_direct_pages ) ) {
|
156 |
$dir = trailingslashit( ABSPATH . $uri );
|
@@ -163,7 +166,7 @@ function wp_cache_ob_callback($buffer) {
|
|
163 |
global $cache_path, $cache_filename, $meta_file, $wp_start_time, $supercachedir;
|
164 |
global $new_cache, $wp_cache_meta_object, $file_expired, $blog_id, $cache_compression;
|
165 |
global $wp_cache_gzip_encoding, $super_cache_enabled, $cached_direct_pages;
|
166 |
-
global $wp_cache_404;
|
167 |
|
168 |
$new_cache = true;
|
169 |
|
@@ -203,7 +206,8 @@ function wp_cache_ob_callback($buffer) {
|
|
203 |
if( !empty( $_GET ) || is_feed() || ( $super_cache_enabled == true && is_dir( substr( $supercachedir, 0, -1 ) . '.disabled' ) ) )
|
204 |
$super_cache_enabled = false;
|
205 |
|
206 |
-
$
|
|
|
207 |
if (!$fr) {
|
208 |
$buffer .= "<!-- File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $cache_path ) . $cache_filename . " -->\n";
|
209 |
return $buffer;
|
@@ -228,6 +232,7 @@ function wp_cache_ob_callback($buffer) {
|
|
228 |
"<!--mclude-->\n<?php include_once('" . ABSPATH . "$1'); ?>\n<!--/mclude-->", $buffer);
|
229 |
$store = preg_replace('|<!--mfunc (.*?)-->(.*?)<!--/mfunc-->|is',
|
230 |
"<!--mfunc-->\n<?php $1 ;?>\n<!--/mfunc-->", $store);
|
|
|
231 |
$wp_cache_meta_object->dynamic = true;
|
232 |
/* Clean function calls in tag */
|
233 |
$buffer = preg_replace('|<!--mclude (.*?)-->|is', '<!--mclude-->', $buffer);
|
@@ -238,10 +243,11 @@ function wp_cache_ob_callback($buffer) {
|
|
238 |
if( $gz )
|
239 |
fputs($gz, gzencode( $store . '<!-- super cache gz -->', 1, FORCE_GZIP ) );
|
240 |
} else {
|
|
|
241 |
$log = "<!-- Cached page served by WP-Super-Cache -->\n";
|
242 |
|
243 |
if( $gz || $wp_cache_gzip_encoding ) {
|
244 |
-
$gzdata = gzencode( $buffer . $log . "<!-- Compression = gzip -->",
|
245 |
$gzsize = strlen($gzdata);
|
246 |
}
|
247 |
if ($wp_cache_gzip_encoding) {
|
@@ -250,7 +256,7 @@ function wp_cache_ob_callback($buffer) {
|
|
250 |
array_push($wp_cache_meta_object->headers, 'Content-Length: ' . strlen($gzdata));
|
251 |
// Return uncompressed data & store compressed for later use
|
252 |
fputs($fr, $gzdata);
|
253 |
-
}else{ // no compression
|
254 |
array_push($wp_cache_meta_object->headers, 'Vary: Cookie');
|
255 |
fputs($fr, $buffer.$log);
|
256 |
}
|
@@ -261,6 +267,11 @@ function wp_cache_ob_callback($buffer) {
|
|
261 |
}
|
262 |
$new_cache = true;
|
263 |
fclose($fr);
|
|
|
|
|
|
|
|
|
|
|
264 |
if( $fr2 ) {
|
265 |
fclose($fr2);
|
266 |
@chmod( $tmp_cache_filename, 0666 & ~umask());
|
@@ -322,7 +333,7 @@ function prune_super_cache($directory, $force = false, $rename = false) {
|
|
322 |
if( in_array( $entry, $protected_directories ) )
|
323 |
$oktodelete = false;
|
324 |
if( $oktodelete && !$rename )
|
325 |
-
@rmdir(
|
326 |
}
|
327 |
}
|
328 |
}
|
@@ -331,7 +342,7 @@ function prune_super_cache($directory, $force = false, $rename = false) {
|
|
331 |
if( in_array( $directory, $protected_directories ) )
|
332 |
$oktodelete = false;
|
333 |
if( $oktodelete && !$rename ) {
|
334 |
-
@unlink(
|
335 |
} elseif( $oktodelete && $rename ) {
|
336 |
if( $cache_rebuild_files && substr( $directory, -14 ) != '.needs-rebuild' ) {
|
337 |
if( @rename($directory, $directory . '.needs-rebuild') )
|
@@ -374,7 +385,7 @@ function wp_cache_phase2_clean_expired($file_prefix) {
|
|
374 |
}
|
375 |
|
376 |
function wp_cache_shutdown_callback() {
|
377 |
-
global $cache_path, $cache_max_time, $file_expired, $file_prefix, $meta_file, $new_cache, $wp_cache_meta_object, $known_headers, $blog_id, $wp_cache_gc;
|
378 |
|
379 |
$wp_cache_meta_object->uri = $_SERVER["SERVER_NAME"].preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', $_SERVER['REQUEST_URI']); // To avoid XSS attacs
|
380 |
$wp_cache_meta_object->blog_id=$blog_id;
|
@@ -433,15 +444,27 @@ function wp_cache_shutdown_callback() {
|
|
433 |
@ob_end_flush();
|
434 |
flush(); //Ensure we send data to the client
|
435 |
if ($new_cache) {
|
|
|
|
|
|
|
|
|
|
|
|
|
436 |
$serial = serialize($wp_cache_meta_object);
|
437 |
if( !wp_cache_writers_entry() )
|
438 |
return false;
|
439 |
-
$
|
|
|
440 |
if( !$fr )
|
441 |
@mkdir( $cache_path . 'meta' );
|
442 |
-
$fr = fopen(
|
443 |
fputs($fr, $serial);
|
444 |
fclose($fr);
|
|
|
|
|
|
|
|
|
|
|
445 |
wp_cache_writers_exit();
|
446 |
}
|
447 |
|
@@ -565,8 +588,13 @@ function wp_cache_post_id() {
|
|
565 |
}
|
566 |
|
567 |
function wp_cache_gc_cron() {
|
568 |
-
global $file_prefix;
|
569 |
-
|
|
|
|
|
|
|
|
|
|
|
570 |
}
|
571 |
|
572 |
?>
|
27 |
if( $_SERVER["REQUEST_METHOD"] == 'POST' || get_option('gzipcompression'))
|
28 |
return;
|
29 |
$script = basename($_SERVER['PHP_SELF']);
|
30 |
+
if (!in_array($script, $cache_acceptable_files) && wp_cache_is_rejected($_SERVER["REQUEST_URI"]))
|
|
|
31 |
return;
|
32 |
if (wp_cache_user_agent_is_rejected()) return;
|
33 |
+
if( !is_object( $wp_cache_meta_object ) ) {
|
34 |
+
$wp_cache_meta_object = new CacheMeta;
|
35 |
+
}
|
36 |
if($wp_cache_gzip_encoding)
|
37 |
header('Vary: Accept-Encoding, Cookie');
|
38 |
else
|
151 |
function get_current_url_supercache_dir() {
|
152 |
global $cached_direct_pages, $cache_path;
|
153 |
$uri = preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', str_replace( '/index.php', '/', str_replace( '..', '', preg_replace("/(\?.*)?$/", '', $_SERVER['REQUEST_URI'] ) ) ) );
|
154 |
+
$uri = str_replace( '\\', '', $uri );
|
155 |
$dir = strtolower(preg_replace('/:.*$/', '', $_SERVER["HTTP_HOST"])) . $uri; // To avoid XSS attacs
|
156 |
+
$dir = apply_filters( 'supercache_dir', $dir );
|
157 |
$dir = trailingslashit( $cache_path . 'supercache/' . $dir );
|
158 |
if( is_array( $cached_direct_pages ) && in_array( $_SERVER[ 'REQUEST_URI' ], $cached_direct_pages ) ) {
|
159 |
$dir = trailingslashit( ABSPATH . $uri );
|
166 |
global $cache_path, $cache_filename, $meta_file, $wp_start_time, $supercachedir;
|
167 |
global $new_cache, $wp_cache_meta_object, $file_expired, $blog_id, $cache_compression;
|
168 |
global $wp_cache_gzip_encoding, $super_cache_enabled, $cached_direct_pages;
|
169 |
+
global $wp_cache_404, $gzsize;
|
170 |
|
171 |
$new_cache = true;
|
172 |
|
206 |
if( !empty( $_GET ) || is_feed() || ( $super_cache_enabled == true && is_dir( substr( $supercachedir, 0, -1 ) . '.disabled' ) ) )
|
207 |
$super_cache_enabled = false;
|
208 |
|
209 |
+
$tmp_wpcache_filename = tempnam( $cache_path, "wp-cache");
|
210 |
+
$fr = @fopen($tmp_wpcache_filename, 'w');
|
211 |
if (!$fr) {
|
212 |
$buffer .= "<!-- File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $cache_path ) . $cache_filename . " -->\n";
|
213 |
return $buffer;
|
232 |
"<!--mclude-->\n<?php include_once('" . ABSPATH . "$1'); ?>\n<!--/mclude-->", $buffer);
|
233 |
$store = preg_replace('|<!--mfunc (.*?)-->(.*?)<!--/mfunc-->|is',
|
234 |
"<!--mfunc-->\n<?php $1 ;?>\n<!--/mfunc-->", $store);
|
235 |
+
$store = apply_filters( 'wpsupercache_buffer', $store );
|
236 |
$wp_cache_meta_object->dynamic = true;
|
237 |
/* Clean function calls in tag */
|
238 |
$buffer = preg_replace('|<!--mclude (.*?)-->|is', '<!--mclude-->', $buffer);
|
243 |
if( $gz )
|
244 |
fputs($gz, gzencode( $store . '<!-- super cache gz -->', 1, FORCE_GZIP ) );
|
245 |
} else {
|
246 |
+
$buffer = apply_filters( 'wpsupercache_buffer', $buffer );
|
247 |
$log = "<!-- Cached page served by WP-Super-Cache -->\n";
|
248 |
|
249 |
if( $gz || $wp_cache_gzip_encoding ) {
|
250 |
+
$gzdata = gzencode( $buffer . $log . "<!-- Compression = gzip -->", 3, FORCE_GZIP );
|
251 |
$gzsize = strlen($gzdata);
|
252 |
}
|
253 |
if ($wp_cache_gzip_encoding) {
|
256 |
array_push($wp_cache_meta_object->headers, 'Content-Length: ' . strlen($gzdata));
|
257 |
// Return uncompressed data & store compressed for later use
|
258 |
fputs($fr, $gzdata);
|
259 |
+
} else { // no compression
|
260 |
array_push($wp_cache_meta_object->headers, 'Vary: Cookie');
|
261 |
fputs($fr, $buffer.$log);
|
262 |
}
|
267 |
}
|
268 |
$new_cache = true;
|
269 |
fclose($fr);
|
270 |
+
@chmod( $tmp_wpcache_filename, 0666 & ~umask());
|
271 |
+
if( !@rename( $tmp_wpcache_filename, $cache_path . $cache_filename ) ) {
|
272 |
+
unlink( $cache_path . $cache_filename );
|
273 |
+
rename( $tmp_wpcache_filename, $cache_path . $cache_filename );
|
274 |
+
}
|
275 |
if( $fr2 ) {
|
276 |
fclose($fr2);
|
277 |
@chmod( $tmp_cache_filename, 0666 & ~umask());
|
333 |
if( in_array( $entry, $protected_directories ) )
|
334 |
$oktodelete = false;
|
335 |
if( $oktodelete && !$rename )
|
336 |
+
@rmdir( $entry );
|
337 |
}
|
338 |
}
|
339 |
}
|
342 |
if( in_array( $directory, $protected_directories ) )
|
343 |
$oktodelete = false;
|
344 |
if( $oktodelete && !$rename ) {
|
345 |
+
@unlink( $directory );
|
346 |
} elseif( $oktodelete && $rename ) {
|
347 |
if( $cache_rebuild_files && substr( $directory, -14 ) != '.needs-rebuild' ) {
|
348 |
if( @rename($directory, $directory . '.needs-rebuild') )
|
385 |
}
|
386 |
|
387 |
function wp_cache_shutdown_callback() {
|
388 |
+
global $cache_path, $cache_max_time, $file_expired, $file_prefix, $meta_file, $new_cache, $wp_cache_meta_object, $known_headers, $blog_id, $wp_cache_gc, $wp_cache_gzip_encoding, $gzsize, $cache_filename;
|
389 |
|
390 |
$wp_cache_meta_object->uri = $_SERVER["SERVER_NAME"].preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', $_SERVER['REQUEST_URI']); // To avoid XSS attacs
|
391 |
$wp_cache_meta_object->blog_id=$blog_id;
|
444 |
@ob_end_flush();
|
445 |
flush(); //Ensure we send data to the client
|
446 |
if ($new_cache) {
|
447 |
+
if( $wp_cache_gzip_encoding && !in_array( 'Content-Encoding: ' . $wp_cache_gzip_encoding, $wp_cache_meta_object->headers ) ) {
|
448 |
+
array_push($wp_cache_meta_object->headers, 'Content-Encoding: ' . $wp_cache_gzip_encoding);
|
449 |
+
array_push($wp_cache_meta_object->headers, 'Vary: Accept-Encoding, Cookie');
|
450 |
+
array_push($wp_cache_meta_object->headers, 'Content-Length: ' . $gzsize);
|
451 |
+
}
|
452 |
+
|
453 |
$serial = serialize($wp_cache_meta_object);
|
454 |
if( !wp_cache_writers_entry() )
|
455 |
return false;
|
456 |
+
$tmp_meta_filename = tempnam( $cache_path . 'meta/', "wp-cache" );
|
457 |
+
$fr = @fopen( $tmp_meta_filename, 'w');
|
458 |
if( !$fr )
|
459 |
@mkdir( $cache_path . 'meta' );
|
460 |
+
$fr = fopen( $tmp_meta_filename, 'w');
|
461 |
fputs($fr, $serial);
|
462 |
fclose($fr);
|
463 |
+
@chmod( $tmp_meta_filename, 0666 & ~umask());
|
464 |
+
if( !@rename( $tmp_meta_filename, $cache_path . 'meta/' . $meta_file ) ) {
|
465 |
+
unlink( $cache_path . 'meta/' . $meta_file );
|
466 |
+
rename( $tmp_metae_filename, $cache_path . 'meta/' . $meta_file );
|
467 |
+
}
|
468 |
wp_cache_writers_exit();
|
469 |
}
|
470 |
|
588 |
}
|
589 |
|
590 |
function wp_cache_gc_cron() {
|
591 |
+
global $file_prefix, $wp_cache_gc;
|
592 |
+
|
593 |
+
if( !isset( $wp_cache_gc ) )
|
594 |
+
$wp_cache_gc = 3600;
|
595 |
+
|
596 |
+
if( !wp_cache_phase2_clean_expired($file_prefix ) )
|
597 |
+
update_option( 'wpsupercache_gc_time', time() - ( $wp_cache_gc - 600 ) ); // if GC failed then run it again in 10 minutes
|
598 |
}
|
599 |
|
600 |
?>
|
wp-cache.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: WP Super Cache
|
4 |
Plugin URI: http://ocaoimh.ie/wp-super-cache/
|
5 |
Description: Very fast caching module for WordPress. Once activated, you must <a href="options-general.php?page=wpsupercache">enable the cache</a>. Based on WP-Cache by <a href="http://mnm.uib.es/gallir/">Ricardo Galli Granada</a>.
|
6 |
-
Version: 0.8.
|
7 |
Author: Donncha O Caoimh
|
8 |
Author URI: http://ocaoimh.ie/
|
9 |
*/
|
@@ -257,6 +257,26 @@ function toggleLayer( whichLayer ) {
|
|
257 |
wp_nonce_field('wp-cache');
|
258 |
?>
|
259 |
</form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
260 |
</fieldset>
|
261 |
<?php
|
262 |
|
@@ -322,8 +342,9 @@ function wsc_mod_rewrite() {
|
|
322 |
$home_path = get_home_path();
|
323 |
$home_root = parse_url(get_bloginfo('url'));
|
324 |
$home_root = trailingslashit($home_root['path']);
|
325 |
-
|
326 |
-
|
|
|
327 |
$wprules = implode( "\n", extract_from_markers( $home_path.'.htaccess', 'WordPress' ) );
|
328 |
$wprules = str_replace( "RewriteEngine On\n", '', $wprules );
|
329 |
$wprules = str_replace( "RewriteBase $home_root\n", '', $wprules );
|
@@ -345,12 +366,12 @@ function wsc_mod_rewrite() {
|
|
345 |
$rules .= "AddDefaultCharset {$charset}\n";
|
346 |
$rules .= "CONDITION_RULES";
|
347 |
$rules .= "RewriteCond %{HTTP:Accept-Encoding} gzip\n";
|
348 |
-
$rules .= "RewriteCond %{DOCUMENT_ROOT}{$inst_root}
|
349 |
-
$rules .= "RewriteRule ^(.*) {$inst_root}
|
350 |
|
351 |
$rules .= "CONDITION_RULES";
|
352 |
-
$rules .= "RewriteCond %{DOCUMENT_ROOT}{$inst_root}
|
353 |
-
$rules .= "RewriteRule ^(.*) {$inst_root}
|
354 |
$rules .= "</IfModule>\n";
|
355 |
$rules = apply_filters( 'supercacherewriterules', $rules );
|
356 |
|
@@ -379,18 +400,33 @@ function wsc_mod_rewrite() {
|
|
379 |
} elseif( strpos( $scrules, 'supercache' ) || strpos( $wprules, 'supercache' ) ) { // only write the rules once
|
380 |
$dohtaccess = false;
|
381 |
}
|
|
|
|
|
|
|
|
|
|
|
382 |
if( $dohtaccess && !$_POST[ 'updatehtaccess' ] ) {
|
383 |
if( !is_writeable_ACLSafe( $home_path . ".htaccess" ) ) {
|
384 |
echo "<div style='padding: 2px; background: #ff0'><h4>Cannot update .htaccess</h4><p>The file <code>{$home_path}.htaccess</code> cannot be modified by the web server. Please correct this using the chmod command or your ftp client.</p><p>Refresh this page when the file permissions have been modified.</p><p>Alternatively, you can edit your <code>{$home_path}.htaccess</code> file manually and add the following code (before any WordPress rules):</p>";
|
385 |
echo "<p><pre># BEGIN WPSuperCache\n" . wp_specialchars( $rules ) . "# END WPSuperCache</pre></p></div>";
|
386 |
} else {
|
387 |
-
echo "<div style='padding: 2px; background: #ff0'><p>To serve static html files your server must have the correct mod_rewrite rules added to a file called <code>{$home_path}.htaccess</code><br />
|
|
|
|
|
|
|
|
|
|
|
|
|
388 |
echo "<pre># BEGIN WPSuperCache\n" . wp_specialchars( $rules ) . "# END WPSuperCache</pre></p>";
|
389 |
-
echo
|
390 |
-
echo
|
391 |
-
|
392 |
-
|
393 |
-
|
|
|
|
|
|
|
|
|
394 |
}
|
395 |
} elseif( $dohtaccess && $valid_nonce && $_POST[ 'updatehtaccess' ] ) {
|
396 |
wpsc_remove_marker( $home_path.'.htaccess', 'WordPress' ); // remove original WP rules so SuperCache rules go on top
|
@@ -407,16 +443,14 @@ function wsc_mod_rewrite() {
|
|
407 |
?>
|
408 |
<p>WP Super Cache mod rewrite rules were detected in your <?php echo $home_path ?>.htaccess file. Click the following link to see the lines added to that file. If you have upgraded the plugin make sure these rules match. <a href="javascript:toggleLayer('rewriterules');" title="See your mod_rewrite rules">View mod_rewrite rules</a>
|
409 |
<div id='rewriterules' style='display: none;'>
|
410 |
-
<?php echo "<p><pre># BEGIN WPSuperCache\n" . wp_specialchars( $rules ) . "# END WPSuperCache</pre></p>\n";
|
|
|
|
|
411 |
</div>
|
412 |
<?php
|
413 |
}
|
414 |
// http://allmybrain.com/2007/11/08/making-wp-super-cache-gzip-compression-work/
|
415 |
if( !is_file( $cache_path . '.htaccess' ) ) {
|
416 |
-
$gziprules = "<IfModule mod_mime.c>\n AddEncoding gzip .gz\n AddType text/html .gz\n</IfModule>\n";
|
417 |
-
$gziprules .= "<IfModule mod_deflate.c>\n SetEnvIfNoCase Request_URI \.gz$ no-gzip\n</IfModule>\n";
|
418 |
-
$gziprules .= "<IfModule mod_headers.c>\n Header set Cache-Control 'max-age=300, must-revalidate'\n</IfModule>\n";
|
419 |
-
$gziprules .= "<IfModule mod_expires.c>\n ExpiresActive On\n ExpiresByType text/html A300\n</IfModule>\n";
|
420 |
$gziprules = insert_with_markers( $cache_path . '.htaccess', 'supercache', explode( "\n", $gziprules ) );
|
421 |
echo "<h4>Gzip encoding rules in {$cache_path}.htaccess created.</h4>";
|
422 |
}
|
@@ -892,10 +926,11 @@ function wp_cache_verify_config_file() {
|
|
892 |
return false;
|
893 |
}
|
894 |
copy($wp_cache_config_file_sample, $wp_cache_config_file);
|
|
|
895 |
if( is_file( dirname(__FILE__) . '/wp-cache-config-sample.php' ) ) {
|
896 |
-
wp_cache_replace_line('WPCACHEHOME', "define( 'WPCACHEHOME',
|
897 |
} elseif( is_file( dirname(__FILE__) . '/wp-super-cache/wp-cache-config-sample.php' ) ) {
|
898 |
-
wp_cache_replace_line('WPCACHEHOME', "define( 'WPCACHEHOME',
|
899 |
}
|
900 |
$new = true;
|
901 |
}
|
@@ -941,6 +976,8 @@ function wp_cache_check_link() {
|
|
941 |
}
|
942 |
|
943 |
function wp_cache_check_global_config() {
|
|
|
|
|
944 |
|
945 |
if ( file_exists( ABSPATH . 'wp-config.php') ) {
|
946 |
$global = ABSPATH . 'wp-config.php';
|
@@ -950,7 +987,7 @@ function wp_cache_check_global_config() {
|
|
950 |
|
951 |
$lines = file($global);
|
952 |
foreach($lines as $line) {
|
953 |
-
|
954 |
return true;
|
955 |
}
|
956 |
}
|
3 |
Plugin Name: WP Super Cache
|
4 |
Plugin URI: http://ocaoimh.ie/wp-super-cache/
|
5 |
Description: Very fast caching module for WordPress. Once activated, you must <a href="options-general.php?page=wpsupercache">enable the cache</a>. Based on WP-Cache by <a href="http://mnm.uib.es/gallir/">Ricardo Galli Granada</a>.
|
6 |
+
Version: 0.8.5
|
7 |
Author: Donncha O Caoimh
|
8 |
Author URI: http://ocaoimh.ie/
|
9 |
*/
|
257 |
wp_nonce_field('wp-cache');
|
258 |
?>
|
259 |
</form>
|
260 |
+
<?php
|
261 |
+
if( function_exists( 'apache_get_modules' ) ) {
|
262 |
+
$mods = apache_get_modules();
|
263 |
+
$required_modules = array( 'mod_mime' => 'Required to serve compressed supercache files properly.', 'mod_headers' => 'Required to set caching information on supercache pages. IE7 users will see old pages without this module.', 'mod_expires' => 'Set the expiry date on supercached pages. Visitors may not see new pages when they refresh or leave comments without this module.' );
|
264 |
+
foreach( $required_modules as $req => $desc ) {
|
265 |
+
if( !in_array( $req, $mods ) ) {
|
266 |
+
$missing_mods[ $req ] = $desc;
|
267 |
+
}
|
268 |
+
}
|
269 |
+
if( is_array( $missing_mods ) ) {
|
270 |
+
echo "<h3>Missing Apache Modules</h3>";
|
271 |
+
echo "<p>The following Apache modules are missing. The plugin will work without them but your visitors may see corrupted pages or out of date content.</p>";
|
272 |
+
echo "<ul>";
|
273 |
+
foreach( $missing_mods as $req => $desc ) {
|
274 |
+
echo "<li> $req - $desc</li>";
|
275 |
+
}
|
276 |
+
echo "</ul>";
|
277 |
+
}
|
278 |
+
}
|
279 |
+
?>
|
280 |
</fieldset>
|
281 |
<?php
|
282 |
|
342 |
$home_path = get_home_path();
|
343 |
$home_root = parse_url(get_bloginfo('url'));
|
344 |
$home_root = trailingslashit($home_root['path']);
|
345 |
+
//$inst_root = parse_url(get_bloginfo('wpurl'));
|
346 |
+
//$inst_root = trailingslashit($inst_root['path']);
|
347 |
+
$inst_root = trailingslashit( str_replace( get_option('siteurl'), '', WP_CONTENT_URL ) );
|
348 |
$wprules = implode( "\n", extract_from_markers( $home_path.'.htaccess', 'WordPress' ) );
|
349 |
$wprules = str_replace( "RewriteEngine On\n", '', $wprules );
|
350 |
$wprules = str_replace( "RewriteBase $home_root\n", '', $wprules );
|
366 |
$rules .= "AddDefaultCharset {$charset}\n";
|
367 |
$rules .= "CONDITION_RULES";
|
368 |
$rules .= "RewriteCond %{HTTP:Accept-Encoding} gzip\n";
|
369 |
+
$rules .= "RewriteCond %{DOCUMENT_ROOT}{$inst_root}cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html.gz -f\n";
|
370 |
+
$rules .= "RewriteRule ^(.*) {$inst_root}cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html.gz [L]\n\n";
|
371 |
|
372 |
$rules .= "CONDITION_RULES";
|
373 |
+
$rules .= "RewriteCond %{DOCUMENT_ROOT}{$inst_root}cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html -f\n";
|
374 |
+
$rules .= "RewriteRule ^(.*) {$inst_root}cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html [L]\n";
|
375 |
$rules .= "</IfModule>\n";
|
376 |
$rules = apply_filters( 'supercacherewriterules', $rules );
|
377 |
|
400 |
} elseif( strpos( $scrules, 'supercache' ) || strpos( $wprules, 'supercache' ) ) { // only write the rules once
|
401 |
$dohtaccess = false;
|
402 |
}
|
403 |
+
// cache/.htaccess rules
|
404 |
+
$gziprules = "<IfModule mod_mime.c>\n AddEncoding gzip .gz\n AddType text/html .gz\n</IfModule>\n";
|
405 |
+
$gziprules .= "<IfModule mod_deflate.c>\n SetEnvIfNoCase Request_URI \.gz$ no-gzip\n</IfModule>\n";
|
406 |
+
$gziprules .= "<IfModule mod_headers.c>\n Header set Cache-Control 'max-age=300, must-revalidate'\n</IfModule>\n";
|
407 |
+
$gziprules .= "<IfModule mod_expires.c>\n ExpiresActive On\n ExpiresByType text/html A300\n</IfModule>\n";
|
408 |
if( $dohtaccess && !$_POST[ 'updatehtaccess' ] ) {
|
409 |
if( !is_writeable_ACLSafe( $home_path . ".htaccess" ) ) {
|
410 |
echo "<div style='padding: 2px; background: #ff0'><h4>Cannot update .htaccess</h4><p>The file <code>{$home_path}.htaccess</code> cannot be modified by the web server. Please correct this using the chmod command or your ftp client.</p><p>Refresh this page when the file permissions have been modified.</p><p>Alternatively, you can edit your <code>{$home_path}.htaccess</code> file manually and add the following code (before any WordPress rules):</p>";
|
411 |
echo "<p><pre># BEGIN WPSuperCache\n" . wp_specialchars( $rules ) . "# END WPSuperCache</pre></p></div>";
|
412 |
} else {
|
413 |
+
echo "<div style='padding: 2px; background: #ff0'><p>To serve static html files your server must have the correct mod_rewrite rules added to a file called <code>{$home_path}.htaccess</code><br /> ";
|
414 |
+
if( !function_exists( 'is_site_admin' ) ) {
|
415 |
+
echo "You must edit the file yourself add the following rules.";
|
416 |
+
} else {
|
417 |
+
echo "You can edit the file yourself add the following rules.";
|
418 |
+
}
|
419 |
+
echo " Make sure they appear before any existing WordPress rules.</p>";
|
420 |
echo "<pre># BEGIN WPSuperCache\n" . wp_specialchars( $rules ) . "# END WPSuperCache</pre></p>";
|
421 |
+
echo "<p>Rules must be added to WP_CONTENT_DIR/cache/.htaccess too:</p>";
|
422 |
+
echo "<pre># BEGIN supercache\n" . wp_specialchars( $gziprules ) . "# END supercache</pre></p>";
|
423 |
+
if( !function_exists( 'is_site_admin' ) ) {
|
424 |
+
echo '<form name="updatehtaccess" action="'. $_SERVER["REQUEST_URI"] . '#modrewrite" method="post">';
|
425 |
+
echo '<input type="hidden" name="updatehtaccess" value="1" />';
|
426 |
+
echo '<div><input type="submit" ' . SUBMITDISABLED . 'id="updatehtaccess" value="Update mod_rewrite rules »" /></div>';
|
427 |
+
wp_nonce_field('wp-cache');
|
428 |
+
echo "</form></div>\n";
|
429 |
+
}
|
430 |
}
|
431 |
} elseif( $dohtaccess && $valid_nonce && $_POST[ 'updatehtaccess' ] ) {
|
432 |
wpsc_remove_marker( $home_path.'.htaccess', 'WordPress' ); // remove original WP rules so SuperCache rules go on top
|
443 |
?>
|
444 |
<p>WP Super Cache mod rewrite rules were detected in your <?php echo $home_path ?>.htaccess file. Click the following link to see the lines added to that file. If you have upgraded the plugin make sure these rules match. <a href="javascript:toggleLayer('rewriterules');" title="See your mod_rewrite rules">View mod_rewrite rules</a>
|
445 |
<div id='rewriterules' style='display: none;'>
|
446 |
+
<?php echo "<p><pre># BEGIN WPSuperCache\n" . wp_specialchars( $rules ) . "# END WPSuperCache</pre></p>\n";
|
447 |
+
echo "<p>Rules must be added to " . WP_CONTENT_DIR ."/cache/.htaccess too:</p>";
|
448 |
+
echo "<pre># BEGIN supercache\n" . wp_specialchars( $gziprules ) . "# END supercache</pre></p>"; ?>
|
449 |
</div>
|
450 |
<?php
|
451 |
}
|
452 |
// http://allmybrain.com/2007/11/08/making-wp-super-cache-gzip-compression-work/
|
453 |
if( !is_file( $cache_path . '.htaccess' ) ) {
|
|
|
|
|
|
|
|
|
454 |
$gziprules = insert_with_markers( $cache_path . '.htaccess', 'supercache', explode( "\n", $gziprules ) );
|
455 |
echo "<h4>Gzip encoding rules in {$cache_path}.htaccess created.</h4>";
|
456 |
}
|
926 |
return false;
|
927 |
}
|
928 |
copy($wp_cache_config_file_sample, $wp_cache_config_file);
|
929 |
+
$dir = str_replace( '\\', '/', str_replace( WP_CONTENT_DIR, '', dirname(__FILE__) ) );
|
930 |
if( is_file( dirname(__FILE__) . '/wp-cache-config-sample.php' ) ) {
|
931 |
+
wp_cache_replace_line('WPCACHEHOME', "define( 'WPCACHEHOME', WP_CONTENT_DIR . \"{$dir}/\" );", $wp_cache_config_file);
|
932 |
} elseif( is_file( dirname(__FILE__) . '/wp-super-cache/wp-cache-config-sample.php' ) ) {
|
933 |
+
wp_cache_replace_line('WPCACHEHOME', "define( 'WPCACHEHOME', WP_CONTENT_DIR . \"{$dir}/wp-super-cache/\" );", $wp_cache_config_file);
|
934 |
}
|
935 |
$new = true;
|
936 |
}
|
976 |
}
|
977 |
|
978 |
function wp_cache_check_global_config() {
|
979 |
+
if( WP_CACHE )
|
980 |
+
return true;
|
981 |
|
982 |
if ( file_exists( ABSPATH . 'wp-config.php') ) {
|
983 |
$global = ABSPATH . 'wp-config.php';
|
987 |
|
988 |
$lines = file($global);
|
989 |
foreach($lines as $line) {
|
990 |
+
if (preg_match('/^\s*define\s*\(\s*\'WP_CACHE\'\s*,\s*(?i:TRUE|1)\s*\)\s*;/', $line)) {
|
991 |
return true;
|
992 |
}
|
993 |
}
|