Documentation
The Assets and Helpers Plugin
On Servd, local volumes aren't guaranteed to persist over any extended period of time - it's one of the ways we make high availability work on every project.
Rather than just leave you to figure out an alternative, the Servd Assets and Helpers plugin comes to the rescue. Simply install it, configure it and then use it like any other Craft assets volume. You'll even get a few additional perks for your trouble. 😃
Installing The Plugin With Composer
compose require servd/craft-asset-storage
Installing The Plugin Via The Control Panel
-
Navigate to the Plugin Store in the Craft control panel
-
Search for 'Servd'
-
Select the 'Servd Assets and Helpers' plugin, scroll down and click 'Install'
Configure The Plugin
Creating a New Assets Volume
Servd Asset Volumes can be created from within the Craft control panel in the usual way.
-
Navigate to Settings > Assets > Volumes
-
Click 'New Volume'
-
Give your volume a name and handle
-
Enable 'Assets in this volume have public URLs' and enter `https://cdn2.assets-servd.host` as the 'Base URL'
-
Set the Volume Type to 'Servd Assets Storage'
-
If you are not using the Servd Assets Platform during local development you do not need to fill in the project slug and secret access key fields - Servd will populate these for you once your project is running on the Servd platform
-
If you are using the Servd Assets Platform during local development create two environment variables named `SERVD_PROJECT_SLUG` and `SERVD_SECURITY_KEY` and add these environment variables to the Asset's settings. The values for these environment variables can be found in the Servd dashboard on the Project Settings > Assets page
-
The Subpath field is optional, but should be used if you are creating multiple Asset Volumes for a project. Setting a subpath will stop those volumes from storing their files in the same location and colliding with each other
-
Save your new volume and test it out on Craft's Assets page within the control panel
Other Settings
The plugin has some additional settings which can be found on the Plugin's general settings page within the Craft Control Panel.
Inject CORS tokens using AJAX
When enabled this will cause all of your non-control panel pages to run some javascript to replace any CSRF tokens with fresh ones. This is useful if you are using static caching but also need CSRF protected form submissions to work.
Some other plugins (e.g. Blitz) also provide similar functionality, so make sure that it is only one plugin is performing this action.
Clear Servd's static cache on entry update events
When Servd's static caching is enabled the plugin is able to clear this cache whenever Craft entries are updated. You can tailor or disable this behaviour using the following settings:
Never: Never clear the static cache when entries are saved
Only entries updated via the Control Panel: Only clear the cache if an entry save event originates from a control panel request. This is useful if you allow end-users to create entries but do not want the cache to clear when they do.
Always: Clear the cache whenever a Craft entry is updated, no matter where the update was instigated