Skip to content

Add static brotli compression support.#720

Closed
stathis wants to merge 2027 commits intoAutomattic:trunkfrom
stathis:master
Closed

Add static brotli compression support.#720
stathis wants to merge 2027 commits intoAutomattic:trunkfrom
stathis:master

Conversation

@stathis
Copy link
Copy Markdown

@stathis stathis commented Dec 16, 2019

To be used in conjunction with https://github.com/kjdev/php-ext-brotli

donnchawp and others added 30 commits July 24, 2017 10:59
* Add note about Cloudflare minification on the tester.

* Re-org text and add note about development mode.

Tips from: https://wordpress.org/support/topic/wp-super-cache-not-working-timestamps-dont-match/
)

Sometimes WPCACHEHOME isn't reliable when installs are moved.
…utomattic#310)

* The activation script should create the configuration file/settings

The configuration file and settings are setup the first time the plugin
is loaded, but they should be set up when the plugin is activated.

* Force WPCACHEHOME update if it's not set correctly.

Should fix issues with sites that are transferred to new hosts.
Delete the WP_CACHE and WPCACHEHOME setting from global config file when
deactivating
…ttic#314)

If wp-cache-config.php was left over after a previous activation of the plugin then $cache_path will probably be set so check for that before setting it.
* Add debug log reporting on .htaccess update.

* Show errors if needed when updating .htaccess rules

Also, improve the display of mod_rewrite rules on settings page.
…mattic#316)

Set $wpsc_served_header to true to show a "Served by" header when
serving cached pages. It's now off by default.
ref: https://wordpress.org/support/topic/feature-request-suppress-wp-super-cache-header/
…c#317)

The loop that preloads taxonomies didn't include the code that checks
for the stop condition. Added that now.
ref: https://wordpress.org/support/topic/i-cant-cancel-cache-preload/
…ts. (Automattic#319)

* Replace home_url with siteurl for legacy sites using diff urls

In the past putting WordPress into a separate directory required changes
to the URLs but now it doesn't so use the siteurl instead of home url.
ref: https://wordpress.org/support/topic/cdn-stopped-working-in-v1-5-x/

* Add a note warning the user is the wrong url is used.
…Automattic#318)

* Realpath checks go in one place. Fixes trailing slash prob on Windows

Calling trailingslashit() after realpath() causes problems for Windows
users because it adds a "/" at the end. That makes comparisons
impossible as happened in prune_super_cache() at
https://wordpress.org/support/topic/cannot-delete-cache-manually-wp-sc-1-5-0/#post-9349616

* Invert this check so it's behaves properly!
* Bump version to 1.5.2 and update changelog

* Removed changelog as it's generated from SVN changes.

* Change link from changelog to GH commit list.
…d wp-super-cache

This fixes Automattic#321 by making sure that unlink is not run on NULL or empty cache directories that appear to be leaking into this from some other source.
Fix a critical bug that deletes wp-admin when deleting the plugin
…utomattic#323)

The deactivate function has already deleted the cache directory so
there's no need to do the same thing in the uninstall function.
Automattic#332)

WordPress installs "in their own directory" will sometimes have
different siteurl and home url which can cause problems. This setting
will allow the site administrator to set it correctly.
…attic#324)

* Add checks on directories to make sure they exist or are valid

* Add more checks on directory access including logging.

Added a small mod to wpsc_get_realpath() to avoid a warning when "/" is
passed to the function. https://wordpress.org/support/topic/warning-realpath-open_basedir-restriction-in-effect-file-is-not-within-t/
Other checks include realpath() returning false, and checking if the
cache path exists before working on it.

* Check if $cache_file is true because realpath() can return false
Automattic#337)

If the cache of a feed is older than the most recently updated post then
delete the cached feed and force a regeneration. ref:
https://wordpress.org/support/topic/rss-feed-not-being-seen-as-updated-by-third-party-readers/
* OSSDL CDN: Only check nonce on relevant page loads

In **ossdl-cdn.php** this code is in the global scope:

```php
if ( function_exists( 'wp_verify_nonce' ) )
	$valid_nonce = isset($_REQUEST['_wpnonce']) ?
	 wp_verify_nonce($_REQUEST['_wpnonce'], 'wp-cache') : false;
else
	$valid_nonce = false;
```

So it runs on every request, and because the file is included when the
plugin first loads, it seems to happen before `wp_verify_nonce` is
defined, so it probably is always set to `false` under normal
circumstances.

The `wp_verify_nonce` function is pluggable, though, so if an override
for it gets defined elsewhere by a plugin or something, it might
actually be defined when the above nonce check happens. This then throws
a fatal error because `wp_verify_nonce` uses `wp_get_current_user`,
which is _not_ defined this early.

This commit addresses the issue by moving the nonce check inside the
only function in the file that uses the `$valid_nonce` variable,
`scossdl_off_update`. The `scossdl_off_options` lists this variable
as a global as well, but it's never used, so the commit also removes
that reference.

* No need for global $valid_nonce

The nonce in scossdl_off_update() is only used in that function, at least on the CDN page so it doesn't need to be global.
* Use realpath to compare paths; fixes Automattic#341

* realpath() on Windows uses Windows paths

We have to use realpath() on every path used in a string comparison as realpath() will change a path so it looks like a Windows path on that platform. ie. c:\Windows\....
* Close div; fixes Automattic#339

* Fixed tab indentation of two lines

Minor change to indention of line(s) in this patch.
)

The previous logic would reset the cache location because of the `else` part of the `if()` check..
If the debug log isn't created before debugging is enabled the PHP at
the top that checks for the username/password won't be added.
…utomattic#336)

* Better notifications on preload page and revert sql to fetch posts
Fixes Automattic#326

The function wp_count_posts() only fetches posts of type "post" and some
users have other types of posts to preload.
The preload page notifications weren't clear enough, so this makes them
into proper admin notices.

* Fix use of wpsc_post_count(). props @stodorovic

* Add the "Cancel preload" button to the admin notice too

* Make preload posts more flexible with filters. Props @stodorovic

I added an extra filter, "wpsc_preload_type_args" on the arguments to
send to get_post_types().

* Fix SQL queries, post types return string, and filter. props @stodorovic
…tic#346)

* Don't cache unknown page types, fixes problems with sitemaps
Fixes 325
Sitemaps are usually generated by a plugin that exits immediately which
causes problems for caching as it doesn't know what type of page it is.
This code refuses to cache pages if the plugin doesn't know exactly what
type of page is being served. A debug log entry is also generated.

* Typo fixed in query check.

* Improve detection of sitemaps by using query_vars, props @stodorovic

Add X-Robots-Tag header used by sitemaps.
Fix $headers/$response mixup introduced in 1.5.0

* Use the is_feed from $wp_super_cache_query instead of is_feed().

The variable $wp_super_cache_query[ 'is_feed' ] is set when a sitemap is
detected as well as a feed making it more useful.
donnchawp and others added 7 commits August 16, 2019 13:03
Some of the settings don't work in expert mode because files are served
by mod_rewrite rules so make it clear which ones are affected by
disabling them and printing a message. Prompted by:
https://wordpress.org/support/topic/304-not-modified-greyed-out/
Mobile support is too complicated in this plugin and is probably not
required as themes resize to suit the browser. It can still be enabled
from the advanced settings page.
* Update version number and changelog.

* Update changelog
donnchawp and others added 7 commits January 27, 2020 12:10
* Bump the tested version to 5.3.2

* Check if $value is an array to avoid PHP warnings.

Props @Chillinchiz
ref: https://wordpress.org/support/topic/php-7-4-and-wp-supercache/#post-12335149
* Fix it's -> its

* Document the wp-super-cache-plugins directory
* Update origin pull link

It was going to a 404, probably because SoftLayer was acquired by IBM and is now called/part of IBM Cloud.

* Update ossdl-cdn.php

Change origin pull link again, to a Google search.

Co-authored-by: Donncha Ó Caoimh <donncha@automattic.com>
My day job, we do a pretty good job od serving polls and surveys!
Bump version number, changelog, updated contributors list.
@vlasky
Copy link
Copy Markdown

vlasky commented May 4, 2020

@donnchawp @stathis 's code that adds Brotli support seems straight forward.

Brotli does a lot to further reduce bandwidth usage beyond what can be achieved with gzip. Can you please merge this commit?

To this day, I have been running a shell script under CentOS 7 Linux to perform brotli compression of static assets, served by nginx-more (a Brotli-enabled Nginx build) with the brotli_static configuration option enabled.

It works, but it would be so much more elegant and convenient to have this done by WP Super Cache.

donnchawp and others added 12 commits August 2, 2020 12:42
* is_writeable works fine on non Windows systems.

* Check if ! WIN after checking for Darwin.

Match a whole lot more Unix systems.

* Yoda this.
Some hosts don't want the advanced-cache.php to be overwritten so we
should handle that. If another caching plugin was installed make sure
that we don't clobber their file.
Don't delete the advanced-cache.php if it doesn't belong to this plugin.
* Fix plugin for usage with Debian wordpress package

Debian packages wordpress in a way that a single wordpress instance can
be used to serve multiple websites.  The wp-config.php file is stored
in a well-known location: /etc/wordpress/config-$HOST.php as explained
in the [README.Debian] file.

The package defines DEBIAN_FILE as the filename of the configuration
file.  When it is defined, and if the wp-config.php was not found using
the "traditional" way, use it.

By default, this file is not writable by the application, adding the
following to it is enough to use the plugin:

define('WP_CACHE', true);
define('WPCACHEHOME', '/var/lib/wordpress/wp-content-xxxxx/plugins/wp-super-cache/');

[README.Debian]:https://salsa.debian.org/debian/wordpress/blob/master/debian/README.debian

* Fix formatting of patch

* Check if this file exists

We're checking other locations, might as well check here too.

Co-authored-by: Donncha Ó Caoimh <donncha@automattic.com>
* Add Jetpack codesniffing ruleset

* Add .phpcs.xml.dist
)

* Check $cache_path more carefully to make sure it's real.

dirname() returns '.' if the string does not contain '/' so we need to
check for that, as well as checking for false.

* Use var_export() to make sure it's a string.
Update changelog and version tested
@kraftbj kraftbj changed the base branch from master to trunk April 7, 2026 21:29
@kraftbj kraftbj closed this Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.