Download the PHP package innoweb/silverstripe-fastly without Composer
On this page you can find all versions of the php package innoweb/silverstripe-fastly. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download innoweb/silverstripe-fastly
More information about innoweb/silverstripe-fastly
Files in innoweb/silverstripe-fastly
Package silverstripe-fastly
Short Description Integration of the Fastly CDN for Silverstripe CMS
License BSD-3-Clause
Homepage https://github.com/xini/silverstripe-fastly
Informations about the package silverstripe-fastly
Silverstripe Fastly integration
Overview
Adds Fastly CDN integration to a Silverstripe Site.
Requirements
- Silverstripe CMS 5.x
- Guzzle 7
Note: this version is compatible with Silverstripe 5. For Silverstripe 4, please see the 2 release line.
Installation
Install the module using composer:
Then run dev/build.
Configuration
Silverstripe
You need to add the following configuration to your environment:
Additionally, the following configuration options are available on the Fastly
class:
soft_purge
:[true|false]
flag to enable Fastly soft purges, see https://docs.fastly.com/en/guides/soft-purges. Defaults totrue
verify_ssl
:[true|false]
flag whether Guzzle should verify the SSL certificate. Useful for dev environments. Defaults totrue
debug_log
: if you want to debug the Guzzle calls made to the Fastly API you can configure the path to a log file where all Guzzle requests are logged to. Defaults to''
flush_on_dev_build
:[true|false]
flag whether all content (pages, images, css, js etc.) should be purged from Fastly. Does not use thesoft_purge
feature. Defaults totrue
sitetree_flush_strategy
:'[single|parents|all|smart|everything]'
lets you select the purge strategy used when a page is changed and published. Defaults to'smart'
single
: only the current page URL is purgedparents
: the current page as well as all its parent pages are purgedall
: all pages are purgedsmart
: depending on what fields of the page have changed,single
,parents
orall
is appliedeverything
: all content is purged from the fastly cache. That includes pages, images, css, js etc.
always_include_in_sitetree_flush
: array of page type classes that should always be purged when a page is changed, e.g. a sitemap. Defaults to[]
Image surrogate keys
Because in Silverstripe 4 and 5 we still have no way of getting all image variants (see https://github.com/silverstripe/silverstripe-assets/issues/109), we need to mark all images and image variants with a Surrogate Key in order to purge them.
Because the filename of all image variants in SS 4.4+ have the variant hash to the original filename, e.g. my-file__FitWzYwLDYwXQ.jpg
, we can extract the file name without hash and add it as a surrogate key header. The module then purges the original URL of the file as well as the Surrogate Key to clear the original image as well as all variants. (This might purge other images if there are multiple images with the same name in different folders, but I think we can live with that.)
For Apache, add the following snippet to your .htaccess
file to add the surrogate key:
Fastly
Conditions
type: cache
title: not admin, logged in or form
type: request
title: admin or logged in
Request settings
Headers
VCL snippets
type: recv
title: clean up requests
type: fetch
title: remove cookie header from static content
type: deliver
title: remove session cookie for non-form pages
GEO fencing
To serve different content based on the user's location add the following VCL snippet to your Fastly configuration:
You can choose any or all of the lines above to add to your config, depending on what you need.
For continent and country codes, automatic VARY headers are added to all page requests. You can override this behaviour in your own page controllers using the updateVaryHeader
method.
See https://developer.fastly.com/reference/vcl/variables/geolocation/ and https://developer.fastly.com/solutions/patterns/geofence/ for further information.
License
BSD 3-Clause License, see License
All versions of silverstripe-fastly with dependencies
silverstripe/cms Version ^5
guzzlehttp/guzzle Version ^7.5