So now you've optimized your code - just how fast IS it? How many of those precious milliseconds are being lost in database or API calls - and how much are you saving in that great caching solution you just found? NuxtJS has a timing library that can help...
Start by enabling the server timing module in NuxtJS in nuxt.config.js
server: {
// port: config.localport || 443
port: process.env.PORT || 3000, // Default: 3000
host: process.env.HOST || 'localhost', // default: localhost
timing: true
},
Wrap your external call in the res.timing.start and res.timing.end statements.
const instance = (req, res, next) => {
res.timing.start('header', 'Header pull')
/* Some API or DB call here */
res.timing.end('header')
res.status(200).send()
}
Log the server timing response after your API call
await this.$axios.get(uri)
.then((res) => { console.log('Timing', res.headers['server-timing']))