Deployment guides - Zeit Now

Last year we learned that stale-while-revalidate is the best cache technique for this type of architecture. At that moment, only KeyCDN and StackPath supported it.

We got in contact with Now because it didn’t work with their CDN. It looks like they have finally fixed it:

They call it “Serverless Pre-Rendering” but I think we should stick to the real name, stale-while-revalidate.

Anyway, I think that our first deployment guide could be Now because it’s serverless, it’s cheap and it’s easy to set up. For what I see, their CDN works now on external domains as well.

2 Likes

These are the instructions to deploy in Zeit Now:

  1. Install the now package in your project:
npm install --save-dev now
  1. Add this now.json file:
{
  "version": 2,
  "alias": ["www.your-site.com"], // CHANGE THIS!
  "builds": [
    {
      "src": "build/static/*",
      "use": "@now/static"
    },
    {
      "src": "favicon.ico",
      "use": "@now/static"
    },
    {
      "src": "build/server.js",
      "use": "@now/node"
    }
  ],
  "routes": [
    {
      "src": "/static/(.*)",
      "headers": {
        "cache-control": "max-age=31536000,s-maxage=31536000,immutable"
      },
      "dest": "/build/static/$1"
    },
    { "src": "/favicon.ico", "dest": "/favicon.ico" },
    {
      "src": "/(.*)",
      "headers": { "cache-control": "s-maxage=1,stale-while-revalidate" },
      "dest": "/build/server.js"
    }
  ]
}
  1. Add a CNAME of www.your-site.com to alias.zeit.co in your domain DNS settings.

  2. Deploy Frontity using this command

npx frontity build && npx now --target production

@SantosGuillamot do you feel like doing a guide with this in the docs? :slight_smile:

Sure! I will try to have a first version of the installations (Where should we include the architecture needed to use Frontity and WordPress?) & deploy during this week. I’ll tell you when it is finished and I may need some feedback :grin:

Sure, whatever you need :slight_smile:

I have made the first version of this guide of how to deploy Frontity on Now. @luisherranz When you have some time, could you take a look at it to check if everything makes sense please? :pray:

https://docs.frontity.org/guides/installation-and-deploy/deploy-on-now

1 Like

Looks great to me :slight_smile: