IPNS - how much is the lifetime

when i publish my IPNS site, how long it is online before i need to republish it? 24h? if so, tell me how to make it longer?

Yes, after 24h, the DHT won’t broadcast the IPNS anymore. You should republish them every 12h or so. This to prevent outdated records to pollute the DHT for a long time.

You can set the lifetime flag to set your IPNS lifetime.

Copying from ipfs name publish --help,

-t, --lifetime string - Time duration that the record will be valid for.
Default: 24h.
This accepts durations such as
“300s”, “1.5h” or “2h45m”. Valid time units are

                    "ns", "us" (or "µs"), "ms", "s", "m", "h".

Wondering where you get that help information from… Here’s what I get from ipfs name publish --help (go-ifps 0.4.22):

USAGE
  ipfs name publish <ipfs-path> - Publish IPNS names.

  ipfs name publish [--resolve=false] [--lifetime=<lifetime> | -t]
                    [--allow-offline] [--ttl=<ttl>] [--key=<key> | -k]
                    [--quieter | -Q] [--] <ipfs-path>

  IPNS is a PKI namespace, where names are the hashes of public keys, and
  the private key enables publishing new (signed) values. In both publish
  and resolve, the default name used is the node's own PeerID,
  which is the hash of its public key.

  For more information about each command, use:
  'ipfs name publish <subcmd> --help'

No explanation of the parameters. I have been wondering for a while what the difference between lifetime and ttl is, and how each of these parameters affect the availability of a published definition.

I am surprised by the difference with the help flag. I have go-ipfs 0.4.22 as well.Here’s what I see when I type ipfs name publish --help:

ipfs name publish --help
USAGE
ipfs name publish - Publish IPNS names.

SYNOPSIS
ipfs name publish [–resolve=false] [–lifetime= | -t]
[–allow-offline] [–ttl=] [–key= | -k]
[–quieter | -Q] [–]

ARGUMENTS

  • ipfs path of the object to be published.

OPTIONS

–resolve bool - Check if the given path can be resolved before
publishing. Default: true.
-t, --lifetime string - Time duration that the record will be valid for.
Default: 24h.
This accepts durations such as
“300s”, “1.5h” or “2h45m”. Valid time units are

                        "ns", "us" (or "µs"), "ms", "s", "m", "h".

–allow-offline bool - When offline, save the IPNS record to the the local
datastore without broadcasting to the network
instead of simply failing.
–ttl string - Time duration this record should be cached for.
Uses the same syntax as the lifetime option.
(caution: experimental).
-k, --key string - Name of the key to be used or a valid PeerID, as
listed by ‘ipfs key list -l’. Default: self.
-Q, --quieter bool - Write only final hash.

DESCRIPTION

IPNS is a PKI namespace, where names are the hashes of public keys, and
the private key enables publishing new (signed) values. In both publish
and resolve, the default name used is the node’s own PeerID,
which is the hash of its public key.

You can use the ‘ipfs key’ commands to list and generate more names and their
respective keys.

Examples:

Publish an with your default name:

> ipfs name publish /ipfs/QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy
Published to QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n: /ipfs/QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy

Publish an with another name, added by an ‘ipfs key’ command:

> ipfs key gen --type=rsa --size=2048 mykey
> ipfs name publish --key=mykey /ipfs/QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy
Published to QmSrPmbaUKA3ZodhzPWZnpFgcPMFWF4QsxXbkWfEptTBJd: /ipfs/QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy

Alternatively, publish an using a valid PeerID (as listed by
‘ipfs key list -l’):

ipfs name publish --key=QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n /ipfs/QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy
Published to QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n: /ipfs/QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy

Weird! I tried the exact same command on a virtual server running Debian 9 with go-ipfs 0.4.22, and I got the long output that you showed. But on my MacBook (macOS 10.14 with go-ipfs 0.4.22), I get the short version that I posted.

Back to the main topic, after seeing the long form, I still don’t understand what exactly --lifetime and --ttl do, nor how I can use them to get the result that I want, which is typically a name valid indefinitely, i.e. until I assign a new hash to it.