I’m trying to serve a third party script but proxy it through my site’s domain. Even after following the cookbook guide, I’m still seeing every request miss the cache.
Here’s my layer0.config.js
:
module.exports = {
connector: '@layer0/next',
prerenderConcurrency: 1,
backends: {
plausible: {
domainOrIp: 'plausible.io',
hostHeader: 'plausible.io',
},
},
};
And routes.js
:
.match('/js/measure.js', ({ cache, proxy }) => {
cache({
edge: {
maxAgeSeconds: 60 * 60 * 24 * 365,
staleWhileRevalidateSeconds: 60 * 60,
},
});
proxy('plausible', { path: '/js/plausible.js' });
})
Running curl (curl -o/dev/null -vv https://calmernews-calmernews-default.layer0.link/js/measure.js
) shows a cache miss in the server timing header, and x-0-t
shows oc=pass
. I tried switching to .get()
instead of .match()
and also renamed the file/removed the path
option but didn’t see any change. Is there something else I’m missing in my router?