Closed ahmed-sigmalux closed 1 year ago
This should do it: https://github.com/pmeenan/cf-workers/tree/master/streaming-optimizations
Let me know if you bump into any issues but it should have the latest streaming logic from the font worker with the script proxy code added. Main change to the processing is to the logic that makes sure a chunk doesn't split a link tag in half (now generically checks for all tags).
It's restructured a bit as well to allow for hooking in other rewriters (expect to see more coming soon, particularly to the non-streaming version).
Big thanks, @pmeenan !!!
Reviving this old thread as I think it is an awesome idea, and thanks @pmeenan for the contributions. As I just deployed this and testing it, I'm getting an error on the Google Fonts CSS request, it seems to set the paths to src: url(/workers/scriptproxy/https/fonts.gstatic.com/s/rubik/v14/iJWbBXyIfDnIV7nEt3KSJbVDV49rz8sDE0Uw.ttf)
where my PROXY_PREFIX
is set to /workers/scriptproxy/
in this case. See the misconfigured paths it has set there, which then again feeds into the worker into a loop and generates a long URL with the wrong hostname tripled :-) Is that something that can be adjusted easily? Perhaps Google Fonts has changed recently?
Closing this issue as it looks like the original issue was resolved, and the templates no longer live here and have moved to the workers-sdk monorepo located here: https://github.com/cloudflare/workers-sdk/tree/main/templates
Does anyone have a working script that combines the fast-google-fonts and third-party-scripts examples? I've been able to mash them together, but the processing is slightly different in each example and I want to ensure I'm not introducing any fatal errors or bugs, particularly with content-types, charsets, and chunking.