2017 © Pedro Peláez
 

silverstripe-vendormodule silverstripe-staticpages

Silverstripe static page caching

image

thewebmen/silverstripe-staticpages

Silverstripe static page caching

  • Friday, June 29, 2018
  • by michelsteege
  • Repository
  • 4 Watchers
  • 2 Stars
  • 115 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 20 Versions
  • 22 % Grown

The README.md

SilverStripe Static Pages

Introduction

Generate static cache for pages, a cache file for a page is generated the first time you visit the pages that needs cache but doesn't have cache., (*1)

Requirements

  • SilverStripe CMS ^4.0

Installation

composer require "thewebmen/silverstripe-staticpages"

Run the task: dev/tasks/install-staticpages, (*2)

How to use

By default the module creates static pages for all SiteTree pages, you can change this by adding the method "generatestatic" on a page object and return false if that pages does not need a static version. Example:, (*3)

public function generatestatic(){
    if($this->URLSegment == 'contact-us'){
        return false;
    }
    return true;
}

If you publish a page with static change then the system wil remove the cache for that page and all pages returned by the optional "urlsAffectedByThisPage" method, make sure that this method returns absolute urls. Example:, (*4)

public function urlsAffectedByThisPage(){
    $children = SiteTree::get()->filter('ParentID', $this->ID);
    $urls = [];
    foreach($children as $child){
    $urls[] = $child->AbsoluteURL();
    }
    return $urls;
}

View the uncached version

Uncached versiones are served when viewing the website in stage mode are when you add ?skipcache=1 to the url, (*5)

Dynamic content

If your page contains dynamic content and/or forms then you need to ajax them, (*6)

Tasks

There are three tasks available: * dev/tasks/install-staticpages (create the staticpages folder, create a symlink and modify the htaccess) * dev/tasks/staticpages (generate all static pages, most of the times not needed) * dev/tasks/flush-staticpages (remove all generated pages, useful after a template change), (*7)

Flushing the cache

You can flush the cache just like the regular silverstripe cache by adding ?flush=1 or ?flush=all to the url, where all deletes all static cache and 1 deletes only the cache for the current page. This works only for logged in users with admin rights., (*8)

Pages with query parameters

It is also possible to cache pages with query parameters this is especially useful for pages with pagination. You can do this by creating a file called staticpages_config.php in the root of your website with the following content:, (*9)

<?php

$staticpages_config = [
    'query_params' => ['start']
];

Where ['start'] is an array of query params to cache., (*10)

Todo

  • Find a better way of caching pages with query params

The Versions

29/06 2018

dev-master

9999999-dev

Silverstripe static page caching

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Michel van der Steege

cache silverstripe static performance

29/06 2018

1.0.14

1.0.14.0

Silverstripe static page caching

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Michel van der Steege

cache silverstripe static performance

29/06 2018

1.0.13

1.0.13.0

Silverstripe static page caching

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Michel van der Steege

cache silverstripe static performance

02/05 2018

1.0.12

1.0.12.0

Silverstripe static page caching

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Michel van der Steege

cache silverstripe static performance

01/05 2018

1.0.11

1.0.11.0

Silverstripe static page caching

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Michel van der Steege

cache silverstripe static performance

30/04 2018

1.0.10

1.0.10.0

Silverstripe static page caching

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Michel van der Steege

cache silverstripe static performance

17/04 2018

1.0.9

1.0.9.0

Silverstripe static page caching

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Michel van der Steege

cache silverstripe static performance

17/04 2018

1.0.8

1.0.8.0

Silverstripe static page caching

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Michel van der Steege

cache silverstripe static performance

17/04 2018

1.0.7

1.0.7.0

Silverstripe static page caching

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Michel van der Steege

cache silverstripe static performance

17/04 2018

1.0.6

1.0.6.0

Silverstripe static page caching

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Michel van der Steege

cache silverstripe static performance

21/03 2018

1.0.5

1.0.5.0

Silverstripe static page caching

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Michel van der Steege

cache silverstripe static performance

26/02 2018

1.0.4

1.0.4.0

Silverstripe static page caching

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Michel van der Steege

cache silverstripe static performance

26/02 2018

1.0.3

1.0.3.0

Silverstripe static page caching

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Michel van der Steege

cache silverstripe static performance

23/02 2018

1.0.2

1.0.2.0

Silverstripe static page caching

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Michel van der Steege

cache silverstripe static performance

23/02 2018

1.0.1

1.0.1.0

Silverstripe static page caching

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Michel van der Steege

cache silverstripe static performance

22/02 2018

1.0.0

1.0.0.0

Silverstripe static page caching

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Michel van der Steege

cache silverstripe static performance

22/02 2018

0.1.0

0.1.0.0

Silverstripe static page caching

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Michel van der Steege

cache silverstripe static performance

22/02 2018

0.0.3

0.0.3.0

Silverstripe static page caching

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Michel van der Steege

cache silverstripe static performance

20/02 2018

0.0.2

0.0.2.0

Silverstripe static page caching

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Michel van der Steege

cache silverstripe static performance

20/02 2018

0.0.1

0.0.1.0

Silverstripe static page caching

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Michel van der Steege

cache silverstripe static performance