Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: getkirby/staticache
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.0.2
Choose a base ref
...
head repository: getkirby/staticache
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 9 commits
  • 3 files changed
  • 6 contributors

Commits on Sep 16, 2023

  1. Add note on the core caching logic

    Closes #25
    lukasbestle authored Sep 16, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3cf1f7d View commit details

Commits on Feb 19, 2024

  1. Update README.md

    Just a minor edit to help me understand the directions. Hope this helps, otherwise, you can ignore this if you like. Just want to give back a little. Cheers!
    luxuryluke authored Feb 19, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    e4ef63d View commit details
  2. Merge pull request #31 from luxuryluke/patch-1

    Update README.md
    texnixe authored Feb 19, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    78deea9 View commit details

Commits on Jun 18, 2024

  1. Add support for Kirby 5

    grommasdietz committed Jun 18, 2024
    Copy the full SHA
    36e6d0d View commit details
  2. Add support for Kirby 5

    grommasdietz committed Jun 18, 2024
    Copy the full SHA
    8a0b981 View commit details

Commits on Jun 20, 2024

  1. Merge pull request #33 from grommasdietz/main

    Support for Kirby 5.0 (Alpha)
    bastianallgeier authored Jun 20, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    17fd9bf View commit details

Commits on Jun 29, 2024

  1. Remove nonfunctional NC option

    Fixes #28
    lukasbestle committed Jun 29, 2024

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    lukasbestle Lukas Bestle
    Copy the full SHA
    2c00885 View commit details
  2. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    lukasbestle Lukas Bestle
    Copy the full SHA
    b95786f View commit details
  3. Fix typo

    lukasbestle committed Jun 29, 2024

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    lukasbestle Lukas Bestle
    Copy the full SHA
    50a4980 View commit details
Showing with 175 additions and 121 deletions.
  1. +15 −8 README.md
  2. +2 −2 composer.json
  3. +158 −111 composer.lock
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ With static cache: ~10 ms

A statically cached page will prevent any Kirby logic from executing. This means that Kirby can no longer differentiate between visitors and logged-in users. Every request will be served directly by your web server, even if the response would differ based on the cookies or other request headers.

If your site has any logic in controllers, page models, templates, snippets or plugins that results in different page responses depending on the request, this logic will naturally not be compatible with Staticache.
If your site has any logic in controllers, page models, templates, snippets, or plugins that result in different page responses depending on the request, this logic will naturally not be compatible with Staticache.

If only specific pages are affected by this, you can add them to the cache ignore list (see below) and use Staticache for the rest of your site. Otherwise, using Kirby's default page cache will be the better option overall because Kirby will automatically detect which responses can be cached and which caches can be used for the current request.

@@ -83,7 +83,9 @@ return [

All pages that are not ignored will automatically be cached on their first visit. Kirby will automatically purge the cache when changes are made in the Panel.

Please note that already cached pages are unaffected by changes to the `ignore` option. Your web server will pick up the already created files and will not check if the page is cacheable. If you see cached results from ignored pages, please manually clear your cache directory.
Please note that already cached pages are unaffected by changes to the `ignore` option. Your web server will pick up the already-created files and will not check if the page is cacheable. If you see cached results from ignored pages, please manually clear your cache directory.

Also, note that Kirby's default caching logic applies on top of manually ignored pages. If your template uses any methods that depend on the user session or request headers (e.g. `$kirby->session()`, `csrf()`...), your pages will not be cached.

**Custom cache comment:**

@@ -159,7 +161,7 @@ In any case, please ensure that your web server has read access to the cache fil

### Web server integration

This plugin will automatically generate and store the cache files, however you need to configure your web server to pick the files up and prefer them over a dynamic result from PHP.
This plugin will automatically generate and store the cache files, however, you will need to configure your web server to pick the files up and prefer them over a dynamic result from PHP.

The configuration depends on your used web server:

@@ -168,10 +170,10 @@ The configuration depends on your used web server:
Add the following lines to your Kirby `.htaccess` file, directly after the `RewriteBase` rule.

```
RewriteCond %{DOCUMENT_ROOT}/site/cache/%{SERVER_NAME}/pages/%{REQUEST_URI}/index.html -f [NC]
RewriteCond %{DOCUMENT_ROOT}/site/cache/%{SERVER_NAME}/pages/%{REQUEST_URI}/index.html -f
RewriteRule ^(.*) %{DOCUMENT_ROOT}/site/cache/%{SERVER_NAME}/pages/%{REQUEST_URI}/index.html [END]
RewriteCond %{DOCUMENT_ROOT}/site/cache/%{SERVER_NAME}/pages/%{REQUEST_URI} -f [NC]
RewriteCond %{DOCUMENT_ROOT}/site/cache/%{SERVER_NAME}/pages/%{REQUEST_URI} -f
RewriteRule ^(.*) %{DOCUMENT_ROOT}/site/cache/%{SERVER_NAME}/pages/%{REQUEST_URI} [END]
```

@@ -218,6 +220,11 @@ To load the static cache files from PHP, please place the following code snippet
(function /* staticache */ () {
$root = __DIR__ . '/site/cache';

// only use cached files for static responses, pass dynamic requests through
if (in_array($_SERVER['REQUEST_METHOD'], ['GET', 'HEAD']) === false) {
return;
}

// check if a cache for this domain exists
$root .= '/' . $_SERVER['SERVER_NAME'] . '/pages';
if (is_dir($root) !== true) {
@@ -244,7 +251,7 @@ To load the static cache files from PHP, please place the following code snippet
})();
```

If you want to use the PHP loader, we recommend to use it together with header support (see below). Storing the headers increases performance by a bit and also gives you more accurate responses.
If you want to use the PHP loader, we recommend using it together with header support (see below). Storing the headers increases performance by a bit and also gives you more accurate responses.

### Header support

@@ -272,7 +279,7 @@ You need to adapt your web server configuration accordingly:

Header support in Apache requires [`mod_asis`](https://httpd.apache.org/docs/current/mod/mod_asis.html). Please ensure that your Apache installation has this module installed and enabled.

Afterwards add the following block to your `.htaccess` file to make Apache use `mod_asis` for cached files:
Afterwards, add the following block to your `.htaccess` file to make Apache use `mod_asis` for cached files:

```
<Directory "/var/www/your-site/site/cache">
@@ -305,7 +312,7 @@ Replace the last six lines of the loader function with this code:
## What’s Kirby?
- **[getkirby.com](https://getkirby.com)** – Get to know the CMS.
- **[Try it](https://getkirby.com/try)** – Take a test ride with our online demo. Or download one of our kits to get started.
- **[Documentation](https://getkirby.com/docs/guide)** – Read the official guide, reference and cookbook recipes.
- **[Documentation](https://getkirby.com/docs/guide)** – Read the official guide, reference, and cookbook recipes.
- **[Issues](https://github.com/getkirby/kirby/issues)** – Report bugs and other problems.
- **[Feedback](https://feedback.getkirby.com)** – You have an idea for Kirby? Share it.
- **[Forum](https://forum.getkirby.com)** – Whenever you get stuck, don't hesitate to reach out for questions and support.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
"type": "kirby-plugin",
"license": "MIT",
"homepage": "https://getkirby.com/plugins/getkirby/staticache",
"version": "1.0.2",
"version": "1.0.3",
"authors": [
{
"name": "Bastian Allgeier",
@@ -18,7 +18,7 @@
}
],
"require": {
"getkirby/cms": "^3.8 || ^4.0",
"getkirby/cms": "^3.8 || ^4.0 || ^5.0",
"getkirby/composer-installer": "^1.2"
},
"extra": {
Loading