2017 © Pedro Peláez
 

silverstripe-vendormodule silverstripe-cdnrewrite

Automatically rewrites the URLs of media and assets to use a CDN

image

dorsetdigital/silverstripe-cdnrewrite

Automatically rewrites the URLs of media and assets to use a CDN

  • Monday, July 16, 2018
  • by DorsetDigital
  • Repository
  • 2 Watchers
  • 0 Stars
  • 24 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 2300 % Grown

The README.md

Silverstripe CDN Rewrite

Provides a simple method of rewriting the URLs of assets and resources to allow the use of a subdomain or external CDN service, (*1)

Scrutinizer Code Quality Build Status License Version, (*2)

V2

Please note, the V2 branch introduces a new configuration syntax. If you are using V1 of the module, you will need to change this before it will work correctly. See the configuration notes below for an example of how to set this module up., (*3)

Requirements

*Silverstripe 4.x, (*4)

Installation

  • Install the code with composer require dorsetdigital/silverstripe-cdnrewrite "^2"
  • Run a dev/build?flush to update your project

Usage

The module won't make any changes to your site unless you do a bit of configuration. There are a few options you can set, done in a yml file:, (*5)

---
Name: cdnconfig
---

DorsetDigital\CDNRewrite\CDNMiddleware:
  cdn_rewrite: true
  cdn_domain: 'https://cdn.example.com'
  add_debug_headers: true
  enable_in_dev: true
  enable_in_preview: false
  subdirectory: ''
  add_prefetch: true
  rewrites:
    - '_resources'
    - 'client'

The options are hopefully fairly self explanatory:, (*6)

  • cdn_rewrite - globally enables and disables the module (default false - disabled)
  • cdn_domain - the full domain name of the CDN (required to enable module)
  • add_debug_headers - if enabled, adds extra HTML headers to show the various operations being applied (default false)
  • enable_in_dev - enable the CDN in dev mode (default false)
  • enable_in_preview - enable the rewrites in the CMS preview panel (default false)
  • subdirectory - set this if your site is in a subdirectory (eg. for http://www.example.com/silverstripe - set this to 'silverstripe')
  • add_prefetch - set this to true if you want the module to automatically add a <link rel="dns-prefetch"> tag to your html head to improve performance
  • rewrites - this is a list of the prefixes you wish to rewrite. By default, the CMS exposes content in a _resources directory in the public structure, so you'll probably want that as a minimum. You can add as many additional entires here as required.

Notes

  • The module is disabled in the CMS / admin system unless explicitly enabled with the setting above, so rewrites do not currently happen here
  • When enabled, the module will always add an HTTP header of X-CDN: Enabled to show that it's working, even if none of the other rewrite operations are carried out. If this is not present and you think it should be, ensure that you have set cdn_rewrite to true, that you have specified the cdn_domain in your config file and that you have enable_in_dev set to true if you are testing in dev mode.
  • Extension points are provided in the middleware to allow you to override the search patterns and replacemnts. See the source code for details. (Beware - this can break your site!)

Need help?

Credits

The Versions

16/07 2018

dev-master

9999999-dev https://github.com/DorsetDigital/silverstripe-cdnrewrite

Automatically rewrites the URLs of media and assets to use a CDN

  Sources   Download

BSD-3-Clause

The Requires

 

by Tim Burt

cdn silverstripe

13/06 2018

v1.1.0

1.1.0.0 https://github.com/DorsetDigital/silverstripe-cdnrewrite

Automatically rewrites the URLs of media and assets to use a CDN

  Sources   Download

BSD-3-Clause

The Requires

 

by Tim Burt

cdn silverstripe

12/06 2018

v1.0.2

1.0.2.0 https://github.com/DorsetDigital/silverstripe-cdnrewrite

Automatically rewrites the URLs of media and assets to use a CDN

  Sources   Download

BSD-3-Clause

The Requires

 

by Tim Burt

cdn silverstripe

08/06 2018

v1.0.1

1.0.1.0 https://github.com/DorsetDigital/silverstripe-cdnrewrite

Automatically rewrites the URLs of media and assets to use a CDN

  Sources   Download

BSD-3-Clause

The Requires

 

by Tim Burt

cdn silverstripe

22/05 2018

v1.0.0

1.0.0.0 https://github.com/DorsetDigital/silverstripe-cdnrewrite

Automatically rewrites the URLs of media and assets to use a CDN

  Sources   Download

BSD-3-Clause

The Requires

 

by Tim Burt

cdn silverstripe