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 @mashroom/mashroom-browser-cache as dependency.
After that you can use the service like this:
import type {MashroomCacheControlService} from '@mashroom/mashroom-browser-cache/type-definitions';
export default async (req: Request, res: Response) => {
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,
"maxAgeSec": 1800
}
}
}
- disabled: Disable browser caching (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(
resourceCanContainSensitiveInformation: boolean,
request: Request,
response: Response,
): Promise<void>;
removeCacheControlHeader(response: Response): void;
}