popeindustries / lit

Fast server-rendering and client-hydration of lit-html templates and web components
MIT License
33 stars 4 forks source link

Update template-instance.js #19

Closed cristobal closed 1 year ago

cristobal commented 1 year ago

Temporarly disable use of the templateCache. This just ends up eating a ton of memory on the server side.

What's your thought on this @popeindustries

changeset-bot[bot] commented 1 year ago

⚠️ No Changeset found

Latest commit: c16a5078c725283ab02f4d9b4ebce3e4be0c4dcd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

popeindustries commented 1 year ago

This basically defeats all optimizations and forces template parsing on every request. Are you experiencing cache misses on each request? Can you log the cache length under traffic?

cristobal commented 1 year ago

This basically defeats all optimizations and forces template parsing on every request. Are you experiencing cache misses on each request? Can you log the cache length under traffic?

The cache keys are actually objects not strings we modified the compiled code to this e.g.:

  if (template === void 0) {
    // 
    console.log(`uncached, typeof strings => ${typeof strings}`)
    template = getTemplate(strings);
    templateCache.set(strings, template);
  } else {
    console.log(`cached, typeof strings => ${typeof strings}`)
  }

And we get the following logs: Screenshot 2022-10-07 at 15 06 58

cristobal commented 1 year ago

Closing this new PR coming up.