Gatsby Images don't cache as desired on iPad - caching

I have a slideshow PWA made with Gatsby. Here's the repo (actually a light, unbranded version of the real thing). I've also hosted the build on Netlify.
Steps to repro :
Open the Netlify install, preferably with an iPad.
Add PWA to home screen
Open PWA via the home screen icon ; don't touch anything after it's open
Go to ioPad settings and disable WiFi/Internet
Return to the app and browse the slides
Notice that slide images aren't loaded (we see only the black background)
The images will load fine while connected to the WiFi. Also if you open the slides before turning off the WiFi, they will cache and remain available even if the app is closed and then reopened.
Desired behavior :
That as soon as the app is open, all the images contained in the slides be cached and ready to use without having opened the slides. This app is meant to be used in an environment where WiFi won't be available. I don't want to have to ask the people to open all the slides one by one to make sure the images are cached before usage.
What has been tried :
Generating all the images once :
// src/pages/index.js, line 156 :
<div id="offline">
{data.slides.edges.map((s) => {
return s.node.frontmatter.gallery.map((i, key) => <img src={i} alt="" key={"cache-"+key} />)
})}
</div>
The rationale was that by generating them once, they would immediately be cached and work offline.
Put the header Cache-Control: public, max-age=31536000 ; it was said to create an "agressive" cache policy...
Use for each single slide image.
Tried both the normal <img src="..." /> tags and the gatsby-image <Img fluid="..." /> tag, in the hopes that maybe the latter would come with its own cache policy override.
Searched the documentation for gatsby-plugin-offline and gatsby-plugin-manifest ; I don't feel I'm missing anything there.
The "real" app is about 45MB big, so it's tight but I feel it should be able to cache properly on an iPad. I don't know what I'm missing ; it seems to me like the number one advantage of a PWA is its ability to (reasonably) work offline. What more can I do to make sure the images are cached without having to open all the slides (there's quite a lot on the real app) ?
Thanks so much !

An answer came to me from a stranger on Reddit where I posted the same question.
In my gatsby-config, I had the following options set up :
{
resolve: gatsby-plugin-offline,
options: {
globPatterns: ['**/*.{js,jpg,png,html,css}']
}
},
But apparently I needed to put the globPatterns inside a workboxConfig object :
{
resolve: `gatsby-plugin-offline`,
options: {
workboxConfig: {
globPatterns: ['**/*.{js,jpg,png,html,css}'],
},
}
},
Can't believe I spent nearly 3 days going back and forth on the whole app and the server configs.
Thanks to anyone who took some time to think about my problem even a little !

Related

How to refresh Chrome

I'm building a series of web pages. Some have images on them. I need to update the images and view the result. BUT in the moment Chrome takes the images from some kind of cache or other mechanism. I did a test and created some html with the image. Here's the original image:
<p class="Regular"><img class="img-responsive" max-width="40%" height="auto"
src="/jpg/image30.jpg" ><br/><br/>
That image is old. I uploaded (via WinSCP) a new image30.jpg, but the old one continues to display. I went to what I think the Chrome cache in
C:\Users\username\AppData\Local\Google\Chrome\User Data\Default\Cache
And deleted all files except for data_1, _2, etc.
I went into Chrome's settings and deleted browsing data.
If I change the image name in the Html to some other name, even one which doesn't exist, an image does display, usually an older one.
This also happens with Firefox and Opera.
You can press CTRL + F5 to reload the page without cache. Under google chrome develop tool, we have an option to disable the cache:

LinkedIn Share API not displaying large image thumbnails anymore

I've been using a plugin called Microblog Poster on my hosted Wordpress site to auto-publish blog entries to LinkedIn, Facebook, Twitter, etc.
I have made no changes to the plugin, the plugin hasn't updated, basically everything has been the exact same. However, within the past 5 days, LinkedIn has stopped displaying the shared image as a large image, when it has been consistently sharing it as a large image before.
It will share the image, but it's now a thumbnail, showing approx 140px x 70px to the left of the shared link's title. Normally, it should show as a large, 525px x 275px image above the shared link's title.
Again, no changes have been made to the plugin, my process, or anything. Facebook and Twitter are still displaying normally. I've even done several tests with different posts to confirm it was not a fluke.
Would love any thoughts on how to fix this, or if anyone else is having this issue.
Take a look at the The Open Graph protocol. You have the option to set the size of your image, as they show in their demo. You already know about the og:image property, but what about og:image:width and og:image:height? Check it out...
<meta property="og:image:width" content="400" />
<meta property="og:image:height" content="300" />
This will show a preview of your image in a standard 400x300 format. This should work, because LinkedIn says they read og: tags in determining share previews, according to the official documentation. Although they don't mention :width and :height, I hope they would respect these tags, too, because they are part of the Open Graph Protocol. Hope this helps!

Not show picture from word

Why images not showing when I paste from MS Word.
Ckeditor show that source
<h1><img src="file:///C:\Users\user\AppData\Local\Temp\msohtmlclip1\01\clip_image002.jpg" style="height:88px; width:1005px" /></h1>
This file exist.
Ckeditor version is for AspNet.
Tested on Chrome, IE 10 and IE 11
Your CKEditor is presumably running on a web page, with a http:// address.
Modern browsers don't support embedding images (or anything else) from file:// URLs in http:// pages (or https://, or any other protocol) for security reasons.
This is because there'd be the danger of a malicious site embedding something from your private files (like a document), and then using some security hole to read and upload it elsewhere.
But even if this worked, it wouldn't do you much good: the image isn't uploaded into CKEditor so the image would show up on your computer only. Anyone else watching the page you're editing would see a broken image link.
As far as I know, there's currently no way around uploading the image separately.

Website displays image that is not associated with img src

I have an iOS app that contains a UIWebView, which display a webpage. Sometimes the page displays a different image than the one associated with the src link.
A user sent me a screenshot where it was clear that one of the icon images had been replaced with a completely different image. The same wrong image was displayed in each of the instances where this icon was supposed to be displayed. Refreshing did not solve the issue, but closing and opening the app did. (Or maybe she actually deleted and reinstalled the app.)
The html for the icon is just an img:
<img src = "/the_icon_source">
The img src is hardcoded directly into the HTML file. I therefore don't see that the HTML itself could have been wrong or said anything besides "/the_icon_source".
So how can the wrong image be associated with an image src? Could the server be sending the wrong image when it's asked for "/the_icon_source"? Could the iOS app be caching incorrectly, mixing up images? How to test and fix?
I myself cannot reproduce this issue. I'm not sure how often it occurs, but several users have mentioned it, also for other images on the page. They have only mentioned it occurring in the app, not on the website. This may just be because the app is used more than the website.
My host is Webfaction and the images are served using WebFaction server’s static-only front-end nginx process. The app displays the website in a UIWebView. (Webfaction suppprt merely told me that they served the right images.)
Is the problem not that you have it like this:
img src = "/the_icon_source"
rather than like this:
img src = ".the_icon_source"
If this is sat on a linux server the / will be pointing to the root directory whereas the . or simply the_icon_source would simply point to the directory in which the website is sat which i assume is where the image is also located.

images not loading in Internet Explorer. why?

ive been finally polishing off a website i was building but to my dismay i recently checked the website in Internet Explorer and found the images weren't loading fully.. you can see can the borders for the image but nothing loads in between. i thought it might something i altered on wordpress, but the main page has images from from non wordpress html files and they don't load either.. everything works fine on every other browser except Internet Explorer.. any ideas why? probably a simple fix
here's the website.. . all the code and css is viewable there, if you want my wordpress code let me know
maybe the code just needs to rearranged to make window browsers happy?
any help would be great
Looking at the source for the shop.html, it looks like you are specifying the height of the images, but not the width. Opera, and Firefox are ignoring the width="" and using the default width, but IE is setting it to width="1." I don't know how to change this in Wordpress but if you remove the width="" or add a value it will show correct.
You can see this if you r-click the image line in IE and select properties: it shows as 1X290px.
img src="images/shop/julianduron.jpg" width="" height="290"
hope this helps

Resources