Vlady
Vlady
CDCloudflare Developers
Created by Vlady on 11/17/2024 in #workers-help
How would you force a worker custom domain to open in https?
Found it ✅
3 replies
CDCloudflare Developers
Created by Vlady on 7/17/2024 in #pages-help
My app is 10 times slower in production
The only thing that could raise concerns is not loading the modules fast enough because I do a bunch of dynamic importing in getLoadContext because the worker times out if I import synchronously :/
3 replies
CDCloudflare Developers
Created by Vlady on 7/17/2024 in #pages-help
My app is 10 times slower in production
I've timed every function call in my entry.server.tsx using Server-Timing headers and I don't see anything wrong here
export default async function handleRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext,
context: AppLoadContext,
) {
let t1 = performance.now()

let app = (
<ThemeProvider theme={mTheme}>
<I18nProvider locale="en-GB">
<ApolloProvider client={context.gqlClient}>
<RemixServer context={remixContext} url={request.url} />
</ApolloProvider>
</I18nProvider>
</ThemeProvider>
)

let t2 = performance.now()
context.timing.recordManualTiming('App render', t2 - t1)

await getDataFromTree(app)

let t3 = performance.now()
context.timing.recordManualTiming('getDataFromTree', t3 - t2)

let gqlState = context.gqlClient.extract()

app = (
<ApolloStateContext.Provider value={gqlState}>
{app}
</ApolloStateContext.Provider>
)

let markup = renderToString(app)

let t4 = performance.now()
context.timing.recordManualTiming('renderToString', t4 - t3)

responseHeaders.set('Content-Type', 'text/html')

let timingHeader = context.timing.getHeaderField()
responseHeaders.set('Server-Timing', timingHeader)

let response = new Response('<!DOCTYPE html>' + markup, {
headers: responseHeaders,
status: responseStatusCode,
})

return response
}
export default async function handleRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext,
context: AppLoadContext,
) {
let t1 = performance.now()

let app = (
<ThemeProvider theme={mTheme}>
<I18nProvider locale="en-GB">
<ApolloProvider client={context.gqlClient}>
<RemixServer context={remixContext} url={request.url} />
</ApolloProvider>
</I18nProvider>
</ThemeProvider>
)

let t2 = performance.now()
context.timing.recordManualTiming('App render', t2 - t1)

await getDataFromTree(app)

let t3 = performance.now()
context.timing.recordManualTiming('getDataFromTree', t3 - t2)

let gqlState = context.gqlClient.extract()

app = (
<ApolloStateContext.Provider value={gqlState}>
{app}
</ApolloStateContext.Provider>
)

let markup = renderToString(app)

let t4 = performance.now()
context.timing.recordManualTiming('renderToString', t4 - t3)

responseHeaders.set('Content-Type', 'text/html')

let timingHeader = context.timing.getHeaderField()
responseHeaders.set('Server-Timing', timingHeader)

let response = new Response('<!DOCTYPE html>' + markup, {
headers: responseHeaders,
status: responseStatusCode,
})

return response
}
3 replies