Cloudflare Developers

CD

Cloudflare Developers

Welcome to the official Cloudflare Developers server. Here you can ask for help and stay updated with the latest news

Join

cache API alternatives

One drawback of using KV for the cache is that there is no easy way to purge that cache. With the current approach by using Cache API we put a custom Cache-Tag to a response, let's say category name. And then once we update pages in that category we call CF API to purge cache by that cache tag. There might be a million pages in that category, so we just purge by cache tag and no need to purge cache for each page. Maybe I didn't completely get the idea of the approach used in worker sites (https://blog.cloudflare.com/extending-the-workers-platform/) but looks like it doesn't fit our use case as we can't update millions of pages in KV. I thought maybe we can have different KV namespaces per each category, so when we need to purge the cache - recreate the namespace. There is a limit of 100 namespaces and we might have thousands of categories. ...

With my cloudflare worker I fail with

With my cloudflare worker I fail with the error [mf:err] Cause: RequestContentLengthMismatchError: Request body length does not match content-length header from the following API response: ``` Note: Unnecessary use of -X or --request, POST is already inferred.
content-length: 697 content-type: application/x-www-form-urlencoded...

what s the correct way to consume wasm

what's the correct way to consume wasm for workers? i've been trying the example at https://blog.cloudflare.com/announcing-wasi-on-workers/ with wrangler but it's not happy with import demoWasm from "./demo.wasm"; kind of import (ts complains about a missing loader)

Incremental adoption of micro-frontends ...

I just came across this recent Cloudflare blog post talking about Fragment Piercing. It seems like quite a useful approach for improving a legacy application, but one thing isn't quite clear to me - how do you implement the Piercing Gateway Worker? Specifically, how does the browser know to point to the Piercing Gateway Worker rather than the Legacy Application host/server? Is there a way to point a domain's DNS to a specific CF Worker? Until I found this post, my plan was to just use Workers in conjunction with a client-side Service Worker to intercept requests and manipulate them as necessary. https://blog.cloudflare.com/fragment-piercing/...

cloudflare workers consuming too many api requests for one webpage

Everytime i get make a request to my full stack app in cloudflare pages , 40-60 cloudflare requests are happening & which is consuming my daily limit of workers quickly. Is there any way to minimize the number of requests worker send when i request a web page or can i cache somehow so my users can't request same webpage multiple times to workers & so i can save my workers requests for other users ? Please suggest what are u doing to override these problems

I m trying to run a js worker that calls

I'm trying to run a js worker that calls a rust library (using wasm_bindgen). I haven't found any examples that do this. I've only seen rust-only workers using worker-build. I get Trace: wasm.__wbindgen_add_to_stack_pointer is not a function. Could anyone know what I should try?

I m using D1 and trying to apply a

I'm using D1 and trying to apply a schema.sql file onto it. However, a few statements don't get read (Parsing 3 statements -> Executed 1 command in 9.842563999816775ms), with no error messages. I've narrowed it down to the INSERT INTO command. The first one works, but the next ones don't. 😅 I don't know what to do

Does anyone here know any decent

Does anyone here know any decent distributed databases for CF Workers? I am using MongoDB with their HTTP Data API right now but my requests are ending up almost 5-10 seconds in some regions. Would be great if any recommendations have full text search....

Logs & Websockets

logs will show up once the ws connection has been terminated, from my experience

TBH by far the easiest way to migrate

TBH, by far the easiest way to migrate from Drive to R2 is to get a cheap, high-bandwidth VPS for a day, transfer everything with RClone, and then shut it back down. While you might be saving yourself a dollar or two, the amount of work required to do it would probably cost you more

Could you use a worker to be a websocket

Could you use a worker to be a websocket client? Like say I make a request to wake up a worker, then that worker then connects to a websocket server and waits for messages, then when new messages come in it processes them (or a durable object doesn't really matter)

Question: Are there any plans to support

Question: Are there any plans to support code splitting in workers? i.e: ```typescript ...

Can you create two asyncs in one

Can you create two asyncs in one cloudflare worker? Im trying to apply custom CSS & apply a cookie under a condition but the required responses are different. Not sure how to merge these together

```

Your worker called response.clone(), but did not read the body of both clones. This is wasteful, as it forces the system to buffer the entire response body in memory, rather than streaming it through. This may cause your worker to be unexpectedly terminated for going over the memory limit. If you only meant to copy the response headers and metadata (e.g. in order to be able to modify them), use `new Response(response.body, response)` instead.
Your worker called response.clone(), but did not read the body of both clones. This is wasteful, as it forces the system to buffer the entire response body in memory, rather than streaming it through. This may cause your worker to be unexpectedly terminated for going over the memory limit. If you only meant to copy the response headers and metadata (e.g. in order to be able to modify them), use `new Response(response.body, response)` instead.
^ I don't understand this, as I don't even have a .clone() in my script....

For log storage what makes the most

For log storage, what makes the most sense to use as a backed? R2, D1, or KV? Or something else?

Right now I have built a website that

Right now I have built a website that hides pricing unless a cookie is present. I am using cloudflare workers to restore pricing information through styling when the cookie is present. However, this worker is breaking the "Add to Cart" functionality on my side