Skip to content

Commit f3dc91e

Browse files
committed
Update README.md
Mention that core XML sitemaps can be cached as well.
1 parent 571f674 commit f3dc91e

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Modern and simple full page cache plugin for WordPress inspired by [Cachify](htt
77

88
BC Cache has no settings page - it is intended for webmasters who are familiar with `.htaccess` files and WordPress actions and filters.
99

10+
BC Cache can cache not only HTML pages, but [core XML sitemaps](https://make.wordpress.org/core/2020/07/22/new-xml-sitemaps-functionality-in-wordpress-5-5/) as well. Technically, any content type generated by WordPress for front-end requests routed via root `index.php` file can be handled provided that output generation triggers [`template_redirect`](https://developer.wordpress.org/reference/hooks/template_redirect/) hook.
11+
1012
## Requirements
1113

1214
* Apache webserver with [mod_rewrite](https://httpd.apache.org/docs/current/mod/mod_rewrite.html) enabled
@@ -17,8 +19,7 @@ BC Cache has no settings page - it is intended for webmasters who are familiar w
1719

1820
* BC Cache has not been tested on WordPress multisite installation.
1921
* BC Cache has not been tested on Windows servers.
20-
* BC Cache can only serve requests without filename in path, ie. `/some/path` or `some/other/path/`, but not `/some/path/to/filename.html`.
21-
* BC Cache does not support [content negotation](https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation#the_accept_header). If contents of URL are deemed cacheable, content is always returned as `text/html` regardless of `Accept` header send by client.
22+
* BC Cache does not support [content negotation](https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation) via `Accept` header.
2223

2324
## Installation
2425

@@ -85,21 +86,19 @@ AddDefaultCharset utf-8
8586
RewriteCond %{HTTP_HOST} ^([^:]+)(:[0-9]+)?$
8687
RewriteRule .* - [E=BC_CACHE_HOST:%1]
8788
88-
# Set path subdirectory (must end with slash).
89-
RewriteRule .* - [E=BC_CACHE_PATH:%{REQUEST_URI}/]
89+
# Set path subdirectory - its suffix depends on whether URI ends with slash or not.
90+
RewriteRule .* - [E=BC_CACHE_PATH:%{REQUEST_URI}/@file/]
9091
RewriteCond %{REQUEST_URI} /$
91-
RewriteRule .* - [E=BC_CACHE_PATH:%{REQUEST_URI}]
92+
RewriteRule .* - [E=BC_CACHE_PATH:%{REQUEST_URI}@dir/]
9293
9394
# Set request variant (by default there is only empty one).
9495
RewriteRule .* - [E=BC_CACHE_REQUEST_VARIANT:]
9596
96-
# Optionally, serve gzipped version of HTML file.
97-
RewriteRule .* - [E=BC_CACHE_FILE:index%{ENV:BC_CACHE_REQUEST_VARIANT}.html]
97+
# Optionally, serve gzipped version of the file.
98+
RewriteRule .* - [E=BC_CACHE_FILE:index%{ENV:BC_CACHE_REQUEST_VARIANT}]
9899
<IfModule mod_mime.c>
99100
RewriteCond %{HTTP:Accept-Encoding} gzip
100-
RewriteRule .* - [E=BC_CACHE_FILE:index%{ENV:BC_CACHE_REQUEST_VARIANT}.html.gz]
101-
AddType text/html .gz
102-
AddEncoding gzip .gz
101+
RewriteRule .* - [E=BC_CACHE_FILE:index%{ENV:BC_CACHE_REQUEST_VARIANT}.gz]
103102
</IfModule>
104103
105104
# Main rules: serve only GET requests with whitelisted query string fields coming from anonymous users.
@@ -143,6 +142,8 @@ If there was a settings page, following filters would likely become plugin setti
143142

144143
* `bc-cache/filter:can-user-flush-cache` - filters whether current user can clear the cache. By default, any user with `manage_options` capability can clear the cache.
145144
* `bc-cache/filter:html-signature` - filters HTML signature appended to HTML files stored in cache. You can use this filter to get rid of the signature: `add_filter('bc-cache/filter:html-signature', '__return_empty_string');`
145+
* `bc-cache/filter:cached-response-headers` - filters HTTP response headers generated by WordPress/PHP that are kept when cache entry is created. These headers are then sent as additional response headers with cached content. By default following headers are kept: `Content-Type`, `Link`, `X-Robots-Tag`, `X-BC-Cache-Generated`. Note that `Content-Type` header is crucial for proper delivery of cached content and thus is always preserved.
146+
* `bc-cache/filter:cache-generation-timestamp-format` - filters format of cache generation timestamp. This timestamp is included in HTML signature and in `X-BC-Cache-Generated` HTTP response header. The value must be a valid `$format` argument for [`wp_date()`](https://developer.wordpress.org/reference/functions/wp_date/).
146147

147148
#### Filters for advanced functions
148149

@@ -285,7 +286,7 @@ This way cached pages can be served to front-end users too. Cookie name and cont
285286

286287
## Request variants
287288

288-
Sometimes a different HTML is served as response to request to the same URL, typically when particular cookie is set or request is made by particular browser/bot. In such cases, BC Cache allows to define request variants and cache/serve different HTML responses based on configured conditions. A typical example is the situation in which privacy policy notice is displayed until site visitor accepts it. The state (cookie policy accepted or not) is often determined based on presence of particular cookie. Using request variants, BC Cache can serve visitors regardless if they have or have not accepted the cookie policy.
289+
Sometimes a different response body is served to request to the same URL, typically when particular cookie is set or request is made by particular browser/bot. In such cases, BC Cache allows to define request variants and cache/serve different response body based on configured conditions. A typical example is the situation in which privacy policy notice is displayed until site visitor accepts it. The state (cookie policy accepted or not) is often determined based on presence of particular cookie. Using request variants, BC Cache can serve visitors regardless if they have or have not accepted the cookie policy.
289290

290291
### Request variant configuration example
291292

@@ -312,7 +313,7 @@ The [default configuration](#installation) needs to be extended as well and set
312313
RewriteRule .* - [E=BC_CACHE_REQUEST_VARIANT:_cna]
313314
```
314315

315-
Important: Variant names are appended to basename part of cache file names, so `index.html` becomes `index_cna.html` and `index.html.gz` becomes `index_cna.html.gz` in the example above. To make sure your setup will work, use only letters from `[a-z0-9_-]` range as variant names.
316+
Important: Variant names are appended to basename part of cache file names, so `index` becomes `index_cna` and `index.gz` becomes `index_cna.gz` in the example above. To make sure your setup will work, use only letters from `[a-z0-9_-]` range as variant names.
316317

317318
## Cache warm up
318319

0 commit comments

Comments
 (0)