Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate Requests when using cache key #1515

Closed
1 of 5 tasks
MarcGodard opened this issue Dec 29, 2019 · 12 comments
Closed
1 of 5 tasks

Duplicate Requests when using cache key #1515

MarcGodard opened this issue Dec 29, 2019 · 12 comments
Assignees
Labels

Comments

@MarcGodard
Copy link

MarcGodard commented Dec 29, 2019

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

  • Always
  • Sometimes
  • Rarely
  • Unable
  • I didn’t try
Software Version
Steal version 2.2.4
Steal-tools version 2.2.5
node -v v12.6.0
npm -v 6.9.0
Browser All
Operating system All
@MarcGodard
Copy link
Author

Can someone respond? I notice that this cache key feature is still not working as expected.

@matthewp
Copy link
Member

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 matthewp added the bug label Apr 30, 2020
@MarcGodard
Copy link
Author

@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
})

@matthewp
Copy link
Member

I think you need to add cacheVersion to your server-production config. That's how it knows to append the version number.

if(loader.isEnv("production") && loader.cacheVersion) {

@MarcGodard
Copy link
Author

@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?

@matthewp
Copy link
Member

matthewp commented May 1, 2020

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');

@MarcGodard
Copy link
Author

@matthewp Yes, that worked. Unfortunately, I cannot deploy it with that.

@matthewp
Copy link
Member

matthewp commented May 1, 2020

I'm looking into a possible fix.

@matthewp
Copy link
Member

matthewp commented May 1, 2020

Couple of things:

  1. I'm seeing a bug in the cache extension where it puts the version number on twice for some reason.
  2. This would have to be a new option, something like renderingCacheVersion so it only applies to what gets rendered SSR. This would be something that only the CSS plugin knows about (for now).

@matthewp matthewp self-assigned this May 1, 2020
@matthewp
Copy link
Member

matthewp commented May 1, 2020

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.

@matthewp
Copy link
Member

matthewp commented May 1, 2020

Moving this to done-css.

@matthewp
Copy link
Member

matthewp commented May 1, 2020

Moved here: donejs/css#66

@matthewp matthewp closed this as completed May 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants