diff --git a/CHANGELOG.md b/CHANGELOG.md index 23ccbbe31b..d30fd646a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added `saveBandwidthOverCache` parameter for skipping caching for products data - @andrzejewsky (#3706) - New zoom effect for product gallery images - @Michal-Dziedzinski (#2755) - Product Page Schema implementation as JSON-LD - @Michal-Dziedzinski (#3704) +- Add `/cache-version.json` route to get current cache version ### Fixed - Fixed Search product fails for category filter when categoryId is string - @adityasharma7 (#3929) diff --git a/core/scripts/server.ts b/core/scripts/server.ts index e2b7efe15f..3cb9450e48 100755 --- a/core/scripts/server.ts +++ b/core/scripts/server.ts @@ -2,6 +2,7 @@ import { serverHooksExecutors } from '@vue-storefront/core/server/hooks' let config = require('config') const path = require('path') const glob = require('glob') +const fs = require('fs') const rootPath = require('app-root-path').path const resolve = file => path.resolve(rootPath, file) const serverExtensions = glob.sync('src/modules/*/server.{ts,js}') @@ -146,6 +147,12 @@ app.use('/service-worker.js', serve('dist/service-worker.js', false, { app.post('/invalidate', invalidateCache) app.get('/invalidate', invalidateCache) +function cacheVersion (req, res) { + res.send(fs.readFileSync(resolve('core/build/cache-version.json'))) +} + +app.get('/cache-version.json', cacheVersion) + app.get('*', (req, res, next) => { if (NOT_ALLOWED_SSR_EXTENSIONS_REGEX.test(req.url)) { apiStatus(res, 'Vue Storefront: Resource is not found', 404)