Mashroom Browser Cache
Plugin for Mashroom Server, a Integration Platform for Microfrontends.
This plugin adds a Service to manage cache control headers. It allows to disable the cache globally.
Usage
If node_modules/@mashroom is configured as plugin path just add this package as dependency.
After that you can use the service like this:
import type {MashroomCacheControlService} from '@mashroom/mashroom-browser-cache/type-definitions';
const cacheControlService: MashroomCacheControlService = req.pluginContext.services.browserCache.cacheControl;
await cacheControlService.addCacheControlHeader(req, res);
You can override the default config in your Mashroom config file like this:
{
"plugins": {
"Mashroom Cache Control Services": {
"disabled": false,
"disabledWhenAuthenticated": false,
"maxAgeSec": 1800
}
}
}
- disabled: Disable browser caching (default: false)
- disabledWhenAuthenticated: Disable browser caching when the user is authenticated (default: false)
- maxAgeSec: Max age in seconds (default: 1800)
Services
MashroomCacheControlService
The Cache Control service is accessible through pluginContext.services.browserCache.cacheControl
Interface:
export interface MashroomCacheControlService {
addCacheControlHeader(request: ExpressRequest, response: ExpressResponse): Promise<void>;
removeCacheControlHeader(response: ExpressResponse): void;
}