You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Challenge for us is that we don't know which URLs our users (other devs) may want to preload.
As example, in theory we could scan the rendered HTML for all links, and prefetch them all. But if a page would have hundreds of links, then that doesn't sound optimal.
I think what Wikipedia does (and what McMaster-Carr does in the video) is to prefetch the URL on hover
We could add a JS script that would add a <link rel="prefetch"> tag when hovering over <a href="..."> tags.
IMO this would make sense to define as a standalone plugin, which would define a single JS file that adds this behaviour.
I came across this articles ("Offline cookbook"). Based on that, it seems it would be possible with django-components, but it also seems incredibly complex.
The challenge is that we don't know which pages should be cached and which should not. (E.g. we don't want to cache transactional pages)
There was another article in the series talking about having same or different expiration policies for service worker and server caching. If we wanted to allow to manage the those policies independently, it feels complex enough that it would deserve a separate project and someone to own it.
BUT, if the service worker cache could be configured to behave based on cache HTTP headers, then all the caching would be configured at the point where user creates Django's HttpResponse to send back.
IMO this would again make sense as a standalone plugin, which would define a two JS files - one to register the service worker, and one for the service worker itself.
We kinda do this already, in a sense that the CSS defined for individual components (Component.css) will be inlined into the HTML into <head>. This does not apply to CSS from Component.Media.css, which is only linked as <link href="...">.
For more fine-tuned definition of what the "Critical CSS" is, I think this already has to be decided by the users.
I think this has to be done by users. Because IMO it'd make sense only if the image did not have any styling applied that'd define the size. But if image's size was defined in CSS, then we'd need to somehow know which CSS rule applies to the image. And that's what browsers do.
I'd leave this one again up to individual users / projects. In theory we could take all images mentioned in the HTML, put them in a single image, save that image temporarily, and serve that. But we wouldn't be able to tell which images are frequently used, and it could lead to just generating loads of files.
This is based on the discussion in #717.
I think it would be great to eventually implement these, so I'm making an issue for this, so we can track progress for this.
Original video: https://youtu.be/-Ln-8QM8KhQ?feature=shared
Summary
❌ 2. CDN caching
3. Service worker caching
4. Asset preloading
5. Critical CSS
❌ 6. Fixed size images
❌ 7. Image sprites
My analysis
Prefetch HTML (0:55)
<link rel="prefetch">
tag when hovering over<a href="...">
tags.CDN caching (2:03)
Service worker caching (2:36)
HttpResponse
to send back.Asset preloading (3:29)
<head>
, so I think not much more to do here.<head>
.url(...)
definitions.url(...)
on every request.Critical CSS (5:33)
Component.css
) will be inlined into the HTML into<head>
. This does not apply to CSS fromComponent.Media.css
, which is only linked as<link href="...">
.Fixed size images (7:36)
Image sprites (8:32)
Loading only needed JS (9:04)
The text was updated successfully, but these errors were encountered: