JavaScript SDK 3.0.0
Changed
⚠ BREAKING CHANGE
- Rename SimpleCache.delete to SimpleCache.purge and require purge options to be supplied as the second parameter
We are renaming because "purge" is already a well-known and documented concept for removing content from Fastly's cache.
The new addition of a second argument allows the caller to decide what scope to purge the content from, currently they can choose to purge from all of Fastly ("global") or from the POP that contains the currently executing instance ("pop"). We do not provide a default option right now, in the future we may provide a default option, if we discover a common pattern is being used.
Here is an example of migrating an application using SimpleCache.delete to SimpleCache.purge with the same behaviour:
/// <reference types="@fastly/js-compute" />
import { SimpleCache } from 'fastly:cache';
addEventListener('fetch', event => event.respondWith(app(event)));
async function app(event) {const url = new URL(event.request.url);const path = url.pathname;if (url.searchParams.has('delete')) {- SimpleCache.delete(path);+ SimpleCache.purge(path, { scope: "global" });return new Response(page, { status: 204 });}
let page = SimpleCache.getOrSet(path, async () => {return {value: await render(path),// Store the page in the cache for 1 minute.ttl: 60}});return new Response(page, {headers: {'content-type': 'text/plain;charset=UTF-8'}});}
async function render(path) {// expensive/slow function which constructs and returns the contents for a given pathawait new Promise(resolve => setTimeout(resolve, 10_000));return path;}
Added
- add event.client.tlsCipherOpensslName (49b0c99)
- add event.client.tlsClientCertificate (cf93b62)
- add event.client.tlsClientHello (3d87cb2)
- add event.client.tlsJA3MD5 (2ecf4af)
- add event.client.tlsProtocol (4c91142)
- Rename SimpleCache.delete to SimpleCache.purge and require purge options to be supplied as the second parameter (20113c1)
Prior change: JavaScript SDK 2.5.0
Following change: JavaScript SDK 3.1.0