Giter Club home page Giter Club logo

Comments (3)

micahjon avatar micahjon commented on June 14, 2024 1

@rschristian , thanks for the quick reply!

You're absolutely right--this is simply a case of me not knowing about the 200.html file.

Looks like I can get the behavior I'm looking for by using Vercel rewrites. In case anyone else is running into this, here's my vercel.json config to avoid a flash of green homepage content on dynamic podcast-specific pages (e.g. adblockpodcast.com/podcast/1549059398).

{
  "rewrites": [
    {
      "source": "/podcast/*",
      "destination": "200.html"
    }
  ]
}

It turns out all my pages share a header, so I was able to get a more complete page shell rendered (without content) on dynamic pages by manually creating a blank loading route (e.g. routes/blank-ssr-page.tsx), pre-rendering it, and then just changing destination in the Vercel rewrite to "blank-ssr-page/index.html", e.g.

image

from preact-cli.

rschristian avatar rschristian commented on June 14, 2024

Hmm, I'm not really sure what you expect CLI to do here? We just output static files, how you serve them is mostly out of scope.

there ought to be a way to control what pre-rendered content is used (instead of it having to be the homepage).

This is entirely up to your file server's configuration. Most file servers fallback to /index.html, sounds like you instead want to configure /200.html as your fallback.

Edit:

but it appears this fix is no longer working, or only applies after the service worker is installed.

Yes, you cannot use the service worker's cache if the service worker is not yet installed.

Edit2: To be clear, the role of /200.html is to provide an empty shell to render into when offline or a network request for a page fails. If you start up your server (npm run serve), navigate to it (to load the SW), stop your server, then navigate to say http://localhost:8080/example, the SW will render your app into /200.html (can check the network). This of course is meant to service PWAs, but you can use it as a empty shell fallback if you want, I suppose.

from preact-cli.

rschristian avatar rschristian commented on June 14, 2024

We can definitely do with some better docs here, will add it to the list.

from preact-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.