niconiahi
niconiahi
Explore posts from servers
CDCloudflare Developers
Created by niconiahi on 2/22/2025 in #workers-help
the "Browser Cache TTL" does nothing
thank you so so so much! not even Cloudflare people could point me in the right direction. You rock
4 replies
CDCloudflare Developers
Created by niconiahi on 2/22/2025 in #workers-help
the "Browser Cache TTL" does nothing
if possible, I don't want to set up a Worker that does this, as that would mean many many more incoming requests. Doesn't seem ideal at all
4 replies
CDCloudflare Developers
Created by niconiahi on 2/22/2025 in #workers-help
setting `max-age` headers to served assets is not getting applied
and one last thing: is my Caching Rule correctly configured?? what do you think? this is an example asset full URI https://morfar.app/assets/index-0i6kkekp.js
15 replies
CDCloudflare Developers
Created by niconiahi on 2/22/2025 in #workers-help
setting `max-age` headers to served assets is not getting applied
are there any plans on making the manipulation of max-age a simple configuration through the wrangler config file?
15 replies
CDCloudflare Developers
Created by niconiahi on 2/22/2025 in #workers-help
setting `max-age` headers to served assets is not getting applied
marvelous! thanks !!
15 replies
CDCloudflare Developers
Created by niconiahi on 2/22/2025 in #workers-help
setting `max-age` headers to served assets is not getting applied
No description
15 replies
CDCloudflare Developers
Created by niconiahi on 2/22/2025 in #workers-help
setting `max-age` headers to served assets is not getting applied
what would you do? i'm not a fan of many options. I want a time-consuming option which is optimal. I'm not looking for quick solutions but resilient which makes the flow of the code least magical. The one solution which is more custom but more control which one would you choose in said case?
15 replies
CDCloudflare Developers
Created by niconiahi on 2/22/2025 in #workers-help
setting `max-age` headers to served assets is not getting applied
i'm interested in the Worker approach. Is the above explanation correct on how to approach it?
15 replies
CDCloudflare Developers
Created by niconiahi on 2/22/2025 in #workers-help
setting `max-age` headers to served assets is not getting applied
I wish there was a wrangler.toml config like
[[assets]]
headers = { max_age = 6000 }
[[assets]]
headers = { max_age = 6000 }
that seems super reasonable
15 replies
CDCloudflare Developers
Created by niconiahi on 2/22/2025 in #workers-help
setting `max-age` headers to served assets is not getting applied
the recommendation from AI is instead of having this
assets = { directory = "./build/client/" }
assets = { directory = "./build/client/" }
have this
workers = {
"asset-worker" = "path/to/asset-worker.ts"
}

[[routes]]
pattern = "yourdomain.com/build/client/*"
worker = "asset-worker"

[[routes]]
pattern = "yourdomain.com/*"
worker = "main"
workers = {
"asset-worker" = "path/to/asset-worker.ts"
}

[[routes]]
pattern = "yourdomain.com/build/client/*"
worker = "asset-worker"

[[routes]]
pattern = "yourdomain.com/*"
worker = "main"
seems kind of OK but do i really have to do this to be in control?
15 replies
CDCloudflare Developers
Created by niconiahi on 2/18/2025 in #workers-help
getting 1042 error from calling a "fetch" call within my React Router application
and cache wouldn't be applied either way here as Workers are before cache
really good to know, I noticed problems before where the cache wouldn't HIT even after just a few days, even having the highest TTL value possible (which is about a month or year, I don't remember) two more questions if possible one: for caching you are recommending KV or what? two: would it ever a Cache-Control header work with a Worker? under which circumstance?
12 replies
CDCloudflare Developers
Created by niconiahi on 2/18/2025 in #workers-help
getting 1042 error from calling a "fetch" call within my React Router application
i'm thinking about replacing such caching capabilities with KV but I would prefer relying on web technologies the most i can, to be honest
12 replies
CDCloudflare Developers
Created by niconiahi on 2/18/2025 in #workers-help
getting 1042 error from calling a "fetch" call within my React Router application
here is the full ordeal: context: React Router 7 application, just migrated from Remix, in which context said problem was not existent. Only after the migration it has arised. I also had to go from deploying to Pages to Workers, as recommended in Discord by the React Router team I have a home page which renders a list of products. This products are gotten via a fetch call to this endpoint (https://morfar.niconiahi.workers.dev/en-US/restaurant/1/products/get) like this
export async function loader({ request, context, params }: LoaderFunctionArgs) {
const env = getEnv(context)
const origin = getOrigin(env)
const restaurantId = params.restaurantId
const locale = params.locale
const products = await fetchProducts({ origin, locale, restaurantId })
return {
products
}
}
export async function loader({ request, context, params }: LoaderFunctionArgs) {
const env = getEnv(context)
const origin = getOrigin(env)
const restaurantId = params.restaurantId
const locale = params.locale
const products = await fetchProducts({ origin, locale, restaurantId })
return {
products
}
}
this is the code for the /products/get endpoint
export async function loader({ context, params }: LoaderFunctionArgs) {
const queryBuilder = context.queryBuilder
const restaurantId = params.restaurantId
const locale = params.locale
const products = await getProducts({ locale, queryBuilder, restaurantId })
return data(products, {
headers: {
"Cache-Control": `s-maxage=${31536000}`,
},
})
}
export async function getProducts({
queryBuilder,
restaurantId,
locale,
}: {
queryBuilder: QueryBuilder
restaurantId: number
locale: Locale
}) {
// very heavy D1 computation here
})
export async function loader({ context, params }: LoaderFunctionArgs) {
const queryBuilder = context.queryBuilder
const restaurantId = params.restaurantId
const locale = params.locale
const products = await getProducts({ locale, queryBuilder, restaurantId })
return data(products, {
headers: {
"Cache-Control": `s-maxage=${31536000}`,
},
})
}
export async function getProducts({
queryBuilder,
restaurantId,
locale,
}: {
queryBuilder: QueryBuilder
restaurantId: number
locale: Locale
}) {
// very heavy D1 computation here
})
as you can see it's a simple flow, in my head this should be completely possible. I mean, every call is isolated from each other, what would be the purpose I wonder if this is not allowed this is the wrapper function to be reused when calling this endpoint, very simple as well
export async function fetchProducts({
origin,
restaurantId,
locale,
}: {
origin: string
restaurantId: number
locale: Locale
}) {
const products = await fetch(`${origin}/${locale}/restaurant/${restaurantId}/products/get`, {
headers: {
"Content-Type": "application/json",
},
})
.then(async (response) => {
return response.json()
})
.then((data) => {
return data as Product[]
})
return products
}
export async function fetchProducts({
origin,
restaurantId,
locale,
}: {
origin: string
restaurantId: number
locale: Locale
}) {
const products = await fetch(`${origin}/${locale}/restaurant/${restaurantId}/products/get`, {
headers: {
"Content-Type": "application/json",
},
})
.then(async (response) => {
return response.json()
})
.then((data) => {
return data as Product[]
})
return products
}
12 replies
CDCloudflare Developers
Created by parisholley on 2/13/2025 in #d1-database
how do you make this work, are you
what's this worker proxy? are there any docs for that? i did a quick search but didn't find anything useful
5 replies
CDCloudflare Developers
Created by parisholley on 2/13/2025 in #d1-database
how do you make this work, are you
i'm interested on this as well. It seems that if this is possible, it should be possible to connect to others DB visualizers as well does it use JDBC URL connections?
5 replies