-
Notifications
You must be signed in to change notification settings - Fork 49
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
Don‘t show placeholder if image is served from Browser cache #92
Comments
Hi @toisrael, would you mind sharing a little reproduction of your use case and (especially) a Best, Tim. |
Sure. We’re using gatsby 2.17.0 with background images plugin V0.8.15. Results with FF on Windows: |
I thought bout running the command Best, Tim. |
Hi there! |
I upgraded the plugin to
Thanks! |
It seems both this package and gatsby-image don't support either the browser or disk cache when reloading the main image, which causes server-side / hard-refreshes of any page with background images to be flagged in ImageCache's |
Hi @ALL, as @jamessimone correctly pointed out, the cache object resets on refreshes. You may have a look at my experiments in the chache-storage-try & second-cache-try branches, though both weren't fruitful : (. Would be open for any suggestions, though : ). Best, Tim. |
@timhagn thanks so much for exploring the options. I wonder if anybody on the core Gatsby team has any further experience with this. I believe you’ve worked with them on parts of this package in the past? It does seem bizarre that in both gatsby image and here the base 64 placeholder images do end up getting served from the cache but the loaded image does not. I’ve done some work on gatsby-image in the past but never really looked into the caching side of things. It seems like something the Gatsby team would be incentivized to work on though ... I’m happy to raise an issue on the core gatsby project or if you were open to doing so, that would also be cool. |
Still trying to get this to work... We're now at Keeping at it, but was sick for the last 1 1/2 weeks and am plastered in work anyway % ). Best, Tim. EDIT: @jamessimone Yup, they lent a hand one or two times for |
@timhagn understood! Yes, I can open an issue with them - feel better! |
Currently I see no solution to this. The CacheStorage API only works over https, so local testing would be out of the question:
LocalStorage would trigger problems with the GDPR (or would it?), Cookies even more (and probably even CacheStorage or any other form of "persistence")... Perhaps over at Gatsby they might have some more ideas, but for now I sadly see no way : (. Best and have a nice weekend, Tim. |
Hi there! |
Hi @ALL! As even Kyle Matthews mentioned this as default behavior for Best, nevertheless, Tim. |
Ello, this bothered me in the main I worked on This was prior to native lazy loading support arriving iirc, and my fix there may only work with Intersection Observer API being used as a fallback. I'll look into that soon. My concern was with page loads/refreshes flashing the base64 placeholder very briefly when the original image is cached. As my linked comment describes, it's due to the base64 being inlined in the HTML and keyframes CSS not being possible for inline styles... A recent PR I contributed uses |
Thanks a lot, @polarathene, gonna look into that as soon as possible : )! |
@timhagn Just to confirm, when you've been looking into this yourself, how have you been testing the caching? I had been using I had been noticing an intermittent network caching behaviour when switching between two image sources via the Art Direction feature and an active PR I have waiting for merge which improves the responsiveness of that switch(without the PR it's latency bound, as With Chrome(on Linux), there was some odd network caching behaviour, seemed to send out a request and then return a 304 if content hadn't changed(so it doesn't re-download it if already in cache), as the cache-control from the gatsby server was As I resized across the media condition width to switch the image, no network requests are made for the images besides the first one since a refresh...until a few seconds after load, which was always reproducible, other times it'd trigger is unclear. I'm assuming that's browser dependent on when it decides it's own internal cache can be used( Without Network caching issues aside, the problems discussed here are:
Correct? These are both resolvable (at least for
I should have a PR up soon on the main gatsby repo, I can link it here when I do if that'd be helpful to reference? EDIT: Appears to be some difference between |
My
The options are either to create temporary dummy picture element with sources Using the CSS keyframes should work, but would move the "flicker" frame to hydration phase for slower connections. Doesn't resolve the issue properly, but perhaps less of a UX problem and more acceptable to push it there? A cleaner transition would be a solid colour placeholder for pre-hydration at SSR with the base64/svg placeholder transitioning in via CSS keyframe if the cache isn't detected in 100ms kicking in at hydration. |
@timhagn I don't think it would fall under GDPR if you're only running generic logic on the client, you're not doing anything with personal attributable data, nor sending the data anywhere. If you're just wanting to store some response cache metadata similar to the headers and the URLs match what are on the page content already, it doesn't seem like anything malicious could be done? MDN mentions for img My draft PR for my attempt on
I think I could test locally with HTTPS, maybe give the CacheStorage API a look(and your earlier attempts), or consider storing the response expiry in LocalStorage. I don't see that solution being anymore likely to be accepted into |
Description
Even if images are served from the browsers cache, the placeholder and blur effect is shown.
Steps to reproduce
You could see that behavior when revisiting a site (e.g. https://www.buschmais.de).
Expected result
The Image served from the Browsers cache is used and no placeholder nor blur effects takes place.
At least, if intentional, the behavior should be a configuration option whether or not the placeholder animation should be used in cases where images are from the browser cache.
The text was updated successfully, but these errors were encountered: