Gathering detailed insights and metrics for strapi-plugin-aws-cloudfront
Gathering detailed insights and metrics for strapi-plugin-aws-cloudfront
Invalidate path in Aws CloudFront in terms of content type
npm install strapi-plugin-aws-cloudfront
Typescript
Module System
Min. Node Version
Node Version
NPM Version
41.7
Supply Chain
75.6
Quality
70.5
Maintenance
100
Vulnerability
96.5
License
JavaScript (100%)
Total Downloads
264
Last Day
1
Last Week
6
Last Month
11
Last Year
83
1 Stars
7 Commits
1 Watching
1 Branches
2 Contributors
Latest Version
1.0.0
Package Id
strapi-plugin-aws-cloudfront@1.0.0
Unpacked Size
19.07 kB
Size
6.76 kB
File Count
24
NPM Version
9.5.1
Node Version
18.16.1
Publised On
29 Aug 2023
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
500%
6
Compared to previous week
Last month
1,000%
11
Compared to previous month
Last year
-54.1%
83
Compared to previous year
Tested with Strapi v4 (current)
As a ✅ verified plugin by Strapi team we're available on the Strapi Marketplace as well as In-App Marketplace where you can follow the installation instructions.
It's recommended to use yarn to install this plugin within your Strapi project. You can install yarn with these docs.
1yarn add strapi-plugin-aws-cloudfront@latest
After successful installation you've to re-build your Strapi instance. To archive that simply use:
1yarn build 2yarn develop
or just run Strapi in the development mode with --watch-admin
option:
1yarn develop --watch-admin
./config/plugins.js
or ./config/plugins.ts
for TypeScript projects:
Option | Default | Description |
---|---|---|
client | {} | |
client.distributionId | The distribution id to connect to the CloudFront | |
bulk | true | Activate or not bulk mode (recommended) |
bulkTimeout | 500 | Timeout for the bulk mode (in milliseconds) |
defaultConfig | {} | |
defaultConfig.defaultLocale | Set the default local | |
defaultConfig.prefixDefaultLocale | Prefix the path with the default locale (only if prefixLocalization is set to true ) | |
defaultConfig.prefixLocalization | Prefix the path with the locale (except default locale) | |
defaultConfig.noTrailingSlash | Remove the trailing slash at the end of the url | |
contentTypes | {} | |
contentTypes.<my-content-type-name>.path | [] | List of path to invalidate |
contentTypes.<my-content-type-name>.localizedPath | {} | See below |
contentTypes.<my-content-type-name>.localizedPath.<locale> | [] | List of path to invalidate |
1module.exports = ({ env }) => ({ 2 // ... 3 'aws-cloudfront': { 4 enabled: true, 5 config: { 6 client: { 7 distributionId: env('WEBSITE_CDN'), 8 }, 9 bulk: true, // invalidate multiple urls in one call (default: true) (recommended) 10 bulkTimeout: 500, // milliseconds (default: 500) 11 defaultConfig: { 12 defaultLocale: 'fr', // default locale (default: empty) 13 prefixDefaultLocale: true, // prefix for the default locale (default: false) 14 prefixLocalization: true, // prefix url with /{locale}. Eg: /fr for french locale (default: false) 15 noTrailingSlash: true, // remove trailing slash at the end of url (default: false) 16 }, 17 contentTypes: { 18 'my-content-type-name': { 19 prefixLocalization: false, // override defaultConfig.prefixLocalization 20 path: ['/*'], // invalidate all pages 21 }, 22 'homepage': { 23 localizedPath: { 24 fr: ['/accueil'], 25 en: ['/home'], 26 }, 27 }, 28 'article': { 29 localizedPath: { 30 fr: ['/article/:slug'], // use the `slug` attribute value of `article` content type 31 en: ['/article/:slug'], 32 }, 33 }, 34 }, 35 }, 36 }, 37 // ... 38})
The cache will be invalidate when :
beforeUpdate
beforeUpdateMany
beforeDelete
beforeDeleteMany
afterUpdate
afterUpdateMany
beforeUpdate
beforeUpdateMany
beforeDelete
beforeDeleteMany
afterUpdate
afterUpdateMany
See more about lifecycle events.
In this example:
my-content-type-name
invalidate /*
homepage
in fr
invalidate /fr/accueil
homepage
in en
invalidate /en/home
article
in en
invalidate /en/article/old-slug
and /en/article/new-slug
You can invalidate some path with the service.
Example in src/api/my-api-name/content-types/my-content-type-name/lifecycles.js
:
1module.exports = { 2 afterUpdate(event) { 3 strapi.plugin('aws-cloudfront').service('cloudfront').invalidateByEntry('my-content-type-name', event.result) // need to defined the content type in plugin configurations (see above) 4 strapi.plugin('aws-cloudfront').service('cloudfront').invalidate(`/some-url`) 5 }, 6}
No vulnerabilities found.
No security vulnerabilities found.