Closed MarcGodard closed 4 years ago
Can someone respond? I notice that this cache key feature is still not working as expected.
My guess is that the server-side version is not running the cache extension for some reason. Do you see the one with the cache key first or the one without?
@matthewp I see the one without first.
Could it be something with my service (added here)?
const ssr = require('done-ssr-middleware')
const path = require('path')
module.exports = ssr({
config: path.join(__dirname, '/package.json!npm'),
main: 'site-template/index.stache!done-autorender',
envs: {
'server-production': {
renderingBaseURL: '/dist',
baseURL: 'public',
bundlesPath: 'dist/bundles'
},
'server-development': {
baseURL: 'client'
}
}
}, {
strategy: 'seo',
xhrCache: false,
timeout: 30000
})
I think you need to add cacheVersion
to your server-production config. That's how it knows to append the version number. https://github.com/stealjs/steal/blob/c9dd1eb19ed3f97aeb93cf9dcea5d68ad5d0ced9/src/cache-bust/cache-bust.js#L10
@matthewp when I do that I get this error in the console:
error: ENOENT: no such file or directory, open 'public/dist/bundles/site-template/index.js?v=10&v=10' {"errno":-2,"code":500,"syscall":"open","path":"public/dist/bundles/site-template/index.js?v=10&v=10","statusCode":404,"url":"file:public/dist/bundles/site-template/index.js?v=10&v=10"}
The index.js file is there.
Here are the changes I made:
const ssr = require('done-ssr-middleware')
const path = require('path')
module.exports = ssr({
config: path.join(__dirname, '/package.json!npm'),
main: 'site-template/index.stache!done-autorender',
envs: {
'server-production': {
renderingBaseURL: '/dist',
baseURL: 'public',
bundlesPath: 'dist/bundles',
cacheVersion: process.env.HEROKU_RELEASE_VERSION || 10,
cacheKey: 'v'
},
'server-development': {
baseURL: 'client'
}
}
}, {
strategy: 'seo',
xhrCache: false,
timeout: 30000
})
Also not sure why its there twice index.js?v=10&v=10
You have any thoughts?
Oh yeah, I guess that makes sense, you don't want to do it that way. This might be specific to CSS and not a general issue with the cache extension.
If you can, can you edit your node_modules/done-css/css.js file here: https://github.com/donejs/css/blob/30bf1b52a5c1bb7c1a1a96eadf8ddebceccda168/css.js#L65
And manually add the version just to see if that works?
link.setAttribute("href", css.href + '?v=123');
@matthewp Yes, that worked. Unfortunately, I cannot deploy it with that.
I'm looking into a possible fix.
Couple of things:
renderingCacheVersion
so it only applies to what gets rendered SSR. This would be something that only the CSS plugin knows about (for now).I think the duplicate number is just a product of the test helpers being used in the tests. Not sure it's a real bug, so going to proceed with #2.
Moving this to done-css.
Moved here: https://github.com/donejs/css/issues/66
Bug: When using cache key option, duplicate requests for the same css file (also using doneJS) one without the cache key and one with. In Production only. This Cache Key Feature.
Build doneJS project, Run in Production. Can also see this here: on my website in network