Dovendyret
Private API to fetch data from server on page load or navigation without exposing api to the client
In the server endpoint you proposed that "anyone" can hit you want to use an API key that will be used to authenticate with the external backend. This key will then only be visible on your server.
3 replies
Trigger page-reload on new deployments
Alright thanks a lot!
I haven't thought of the possbility of a reload-loop if my frontend sees different versions of my backend. Wouldn't it still techincally be possible to trigger multiple reloads in a row if my frontend detects a new server A build, reloads and reaches server B which is still deploying?
We haven't had the need for more than 3 servers so far but definitely a good point.
As for the endpoint I think I thought too hard about it. Simply returning a string set during build time and caching it for a short duration seems like a simple and easy solution.
7 replies
Trigger page-reload on new deployments
@Single Thanks for the reponse! It seems you have good knowledge so sorry for ping but I what do you think about this approach?
I have an external Laravel backend running but I'm proxying all my requests through Nitro to this external backend. I could easily create an endpoint for this my question would then be where to store the "deployment ID" for optimal performance?
I'm thinking of two options either KV storage in Nitro or just a static file in the assets/ folder. I assume 100k users polling my KV storage could become quite expensive so static json file seems the best?
I'm thinking a deployment script that creates a file in the assets/ directory with a deployment ID and then an endpoint like this:
export default defineEventHandler(async () => {
const data = await useStorage('assets:server').getItem(
deployment.json)
return data
})
that will be polled by my frontend like this:
export default defineNuxtPlugin(() => {
const { deploymentId } = useRuntimeConfig().public
const interval = setInterval(async () => {
const response = await $fetch('/deployment')
if (response.deploymentId != deploymentId) {
reloadNuxtApp()
clearInterval(interval)
}
}, 5000)
})
7 replies
Best way to cache a pre-rendered SSG project?
I've had the same issue. We have an ecommerce shop with 12 different languages and a lot of SEO content for each language. I've tried pre-rendering all my SEO pages which is around 40k pages and then my server also runs into memory issues.
Pre-prendering this content would be preferable but for now we settled for SWR with redis
11 replies
Pre-render stragety for CMS content
Thanks for reponse 🙏 Yes I'm thinking our own custom module with this logic would be a potential solution for us. Do you have any tips for how I should retrieve the already generated pages from a previous deploy?
7 replies
How to add meta data to specific slugs in a dynamic route
Yea I have the endpoint already. The problem is the CMS is slow as hell and the underlying dstatructure for the pages is a mess... If I don't hit a cache the response time can be upwards 20-30 seconds to get 3000 slugs 😅
20 replies