Download the PHP package innocode-digital/wp-prerender-aws-lambda without Composer
On this page you can find all versions of the php package innocode-digital/wp-prerender-aws-lambda. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download innocode-digital/wp-prerender-aws-lambda
More information about innocode-digital/wp-prerender-aws-lambda
Files in innocode-digital/wp-prerender-aws-lambda
Package wp-prerender-aws-lambda
Short Description Generates HTML for client-side rendered content via AWS Lambda.
License GPL-2.0+
Informations about the package wp-prerender-aws-lambda
AWS Lambda Prerender
Description
Generates HTML for client-side rendered content via AWS Lambda. This plugin sends request to AWS Lambda Prerender function which renders content with Puppeteer and returns HTML back through REST API callback.
Install
-
Preferable way is to use Composer:
`
By default, it will be installed as Must Use Plugin. It's possible to control with
extra.installer-paths
incomposer.json
. -
Alternate way is to clone this repo to
wp-content/mu-plugins/
orwp-content/plugins/
:`
If plugin was installed as regular plugin then activate AWS Lambda Prerender from Plugins page
or WP-CLI: wp plugin activate wp-prerender-aws-lambda
.
Configuration
Add the following constants to wp-config.php
:
`
Create Lambda function on AWS. Expected default name is prerender-production-render but you may use any other. There is a prepared function AWS Lambda Prerender.
Used user should have InvokeFunction
in policy.
`
It's possible to change database table name where HTML will be stored and query argument which is using when serverless function makes request to website.
Usage
Plugin automatically generates HTML on Post/Page and Term save action with updating of related content like Frontpage, but it's possible to control this behavior e.g. if you do not want to update author's archive page on post save then use next filter:
`
Also, plugin generates HTML "on the fly" when someone visits any of object with template e.g. single post and if there is no content in database for current object in current version then cron task will be scheduled to make new request to Lambda.
If theme does not support e.g. date archives then it's possible to disable them at all:
`
Also, it's possible to add custom template in addition to existing:
- Create new template from
Innocode\Prerender\Abstracts\AbstractTemplate
class:
`
- Implement method stubs in your template class.
- Add your template class object to templates collection:
`
By default, plugin uses selector #app
to grab content, i.e. that your client-side
application is wrapped in block with ID app
:
`
If it's needed to change selector use next hook:
`
Notes
Existing templates
post
- Post, Page and Custom Post Typeterm
- Category, Tag and Custom Taxonomy Termauthor
- Author Archivefrontpage
- Front Pagepost_type_archive
- Post Type Archivedate_archive
- Year, Month and Day Archives
Version
It was mentioned above that content has a version, and you may want to upgrade it at some point, most obvious case when something has been changed in client-side rendered layout. In this case it's needed to bump new version:
`
But, you can install Flush Cache Buttons plugin which adds possibility to do this action by clicking on the button in admin panel.
Modify content during prerendering
Sometimes content which is prerendered should be different from what we get on client-side e.g. you may need to exclude certain element. In this case use JavaScript global variable:
`
All versions of wp-prerender-aws-lambda with dependencies
ext-json Version *
aws/aws-sdk-php Version ^3.14
innocode-digital/wp-secrets-manager Version ^1.0
innocode-digital/wp-version Version ^1.0
jaybizzle/crawler-detect Version ^1.2