Basilisk
TTCTheo's Typesafe Cult
•Created by Basilisk on 6/20/2023 in #questions
Secure way of previewing PDF in react app (without storing locally in readable way)
I have a client that wants to securely preview PDF on a public PC.
Normally, PDF is generated on a backend and downloaded to PC.
However, if the user is on a public PC they don't want to store the PDF locally, to prevent a third party from obtaining it.
A solution would be to preview PDF in browser without downloading it.
However, this could still save this PDF to browser cache in a readable way.
Is there a way, library, to show viewer content of PDF but without downloading it on PC in any externally readable way?
Maybe there is a library that encrypts PDF?
App is secured with authorization and authentication and automatic logout.
1 replies
TTCTheo's Typesafe Cult
•Created by Basilisk on 2/24/2023 in #questions
React Query - Slow performance with many small cached requests
I have a list of accordions. Every accordion have items that contain image.
On accordion click, I fetch items text data and image id to speed up list loading and load images later.
Inside an item, I use image id to fetch an image per item. Image is in base64 format.
In every accordion, I can have 10 or more items, so in total there can be few hundreds.
When I open just one or two accordions and cache them, the app is working fine. CPU jumps to 20-30%.
But if I open a lot of accordions and cache them (I can close them), next time I open accordion CPU usage jumps to 100%.
List still works fluent - it displays data instantly, however if at this moment go to diffrent view in my app, request from this view will not be fetched for like few seconds.
My guess is that react is rendering fine but when there are a lot of requested cached in react query than it checks them all to see if they need update or not. While cached is checked, new request (not cached ones) are blocked.
This happens even if staleTime is infinite.
If there is a way to optimize react query, that would be great.
If not, I will probably try to counter this with by fetching images per accordion to make number of react query entries in cache smaller.
10 replies
TTCTheo's Typesafe Cult
•Created by Basilisk on 2/24/2023 in #questions
How can I cache blob image provided by backend (React)?
I have a list of accordions. Every accordion have items that have images.
On accordion click, I fetch items text data and image id to speed up list loading and load images later.
Inside item I use image id to fetch image per item. I get a blob which I convert to URL with URL.createObjectURL(blob)
I use react query, so I can cache and stale request response.
However, even if the request is cached, the image doesn't load instantly after closing and opening accordion, probably because it creates new image URL from blob.
There is even 500ms time fetching per image in image tab in dev tools.
How can I cache this blob image?
Second thing is that it would be nice to not display multiple request in "Fetch/XHR" tab. Maybe there is a way to move it to another tab?
4 replies