question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve browser/server detection for static caching

See original GitHub issue

Version

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:closed
  • Created 6 years ago
  • Comments:19 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
darthtrevinocommented, Mar 23, 2018

Aye aye

1reaction
JonnyBurgercommented, Jan 9, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found