How to stop a nonce from being cached in an inline script, or alternatives to regenerate it if expired?

How to stop a nonce from being cached in an inline script, or alternatives to regenerate it if expired?

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)