Improve browser/server detection for static caching
See original GitHub issueVersion
styled-components: > 2.2.0
I’ve just updated my existing project from 2.0.0. to 2.4.0. and noticed that the SSR CSS tags / rules are not generated correctly anymore. It seems that the rules for the first level components are generated correctly, but all the rules for sub (nested) components are not created anymore.
This is the relevant part of the code (mostly taken directly from the SSR documentation):
const sheet = new ServerStyleSheet()
const html = renderToString(sheet.collectStyles(
<Router location={req.url} context={{}}>
<App serverData={serverData} />
</Router>,
))
const css = sheet.getStyleTags()
I did some testing and this code works perfectly up to 2.2.0. Has something changed in 2.2.1 that causes this issue?
Issue Analytics
- State:
- Created 6 years ago
- Comments:19 (10 by maintainers)
Top Results From Across the Web
Guide for Caching and HTTP Cache Headers for Static Content
Best practices for cache management of static assets and using the correct cache headers like Cache-Control.
Read more >Leverage Browser Caching | PageSpeed Insights
This rule triggers when PageSpeed Insights detects that the response from your server does not include caching headers or if the resources ...
Read more >Leveraging Browser Cache - Hostinger
Website speed is a crucial SEO ranking factor. In this article, you will learn how to improve it by leveraging browser cache.
Read more >Building Better Websites by Caching Assets - Manning
In this article, we'll learn what caching is, how to develop a caching strategy that'll provide the best performance for your website, ...
Read more >Serve static assets with an efficient cache policy - GTmetrix
Serving static assets with an efficient cache policy helps improve page load times on repeat visits by storing these files locally in the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Aye aye
Funny, I just experienced the same issue at the same time… I located the exact version number where it seems to break and it looks like in the 2.2.0 --> 2.2.1 update it started breaking. Going to dig now and see if I can spot the bug.