question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve cache handling of data.json files

See original GitHub issue

🧩 Feature request

Description

Depending on server config data.json files are cached sometimes. I know we can opt out from using them in favor of index.html files, but to have the highest performance I believe data.json is the best way. It would be great if Scully provided a mechanism which would make these files work with cache.

Describe the solution you’d like

The most straightforward thing to do in my opinion is this:

  1. In puppeteerRenderPlugin add something like window['ScullyIOGenerationTime']=${Date.now()}
  2. In TransferStateService in ng-lib load data.json like so:
`/data.json?gen=${ScullyIOGenerationTime}`

This will not only prevent unwanted cache, but will also work fine with being cached in between generations giving even better experience to the user. If there are any drawbacks to this, it can be further improved I believe. But if the proposed solution is good, then I can open a PR.

Describe alternatives you’ve considered

Alternatively I can write a custom plugin in my project to that generation timestamp to my pages and then reprovide patched version of TransferStateService in my project. But it would be much better to solve this on Scully level.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
SanderEliascommented, Apr 19, 2021

This is a good feature request, and we will put it on our list. Don’t expect a solution within a few weeks, but we will land one.

2reactions
SanderEliascommented, May 27, 2021

@yringler I would accept a PR for this. The main problem is how to get the hash back into angular.
The way described has a flaw. We support partial rendering. That means, that your data.json might be generated in multiple sessions/ Scully runs. A solution would have to cater for that. We do have incremental builds in the future, and those can not be hampered by supporting this feature.

Keeping an index would be a possibility, but if you are generating more than a few thousand pages, this might not be a good solution. I did think about this before, but the solution isn’t obvious.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using JSON Object as Cache Data | NCache Docs - Alachisoft
When retrieving cache data as JSON, the data of any custom class can be retrieved as a JsonObject , provided that the cache...
Read more >
Possible to cache JSON to increase performance / load time?
Store your JSON data in a .json file on your PHP server: ... If so, pull the value from storage and echo it...
Read more >
How to manage a large JSON file efficiently and quickly - Sease
Tips and tricks to find out efficient and fast ways to manage a large JSON file in Python using real-world applications.
Read more >
Optimize performance with caching on Databricks
The disk cache contains local copies of remote data. It can improve the performance of a wide range of queries, but cannot be...
Read more >
The Cache API: A quick guide - web.dev
// Retrieve data.json from the server and store the response. cache.put('/data.json') ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found