https://discord.cloudflare.com logo
Join Discord
Powered by
# workers-discussions
  • c

    Chaika

    05/17/2023, 5:21 PM
    The page rule sets that the response should be cached there, sure, but the actual cache process is in the origin contacting part of the sequence
  • c

    Chaika

    05/17/2023, 5:22 PM
    Workers will always run in front of cache. You can use cache in Workers, but you still pay for every invocation
  • f

    frydim1

    05/17/2023, 5:24 PM
    No point in caching if i'm still paying for every request
  • c

    Chaika

    05/17/2023, 5:25 PM
    It's not like with an normal origin it would respond with the cached response in the Pages Rules section just because you overrode it there. That does determine the order of events (i.e a URL Rewrites happen before Page Rules), but specific actions like changing the ssl/tls mode in a configuration rule just set certain values that are used later in the flow
  • u

    Unsmart | Tech debt

    05/17/2023, 5:26 PM
    There still is: Faster responses. Less requests to any external apis that can cost money or go down at higher traffic
  • b

    boywithkeyboard

    05/17/2023, 5:27 PM
    they could've added it similar to the bindings too, to keep consistency
  • f

    frydim1

    05/17/2023, 5:27 PM
    I'm doing 313m requests monthly to my api and 178m are cache hits already
  • f

    frydim1

    05/17/2023, 5:27 PM
    with workers I'd have to pay for 313m requests instead of only 50% of that...so not worth it for me sadly
  • f

    frydim1

    05/17/2023, 5:28 PM
    since what i want to do with the worker can be done with nginx already
  • u

    Unsmart | Tech debt

    05/17/2023, 5:28 PM
    🤷
  • f

    frydim1

    05/17/2023, 5:29 PM
    but this traffic sequence is misleading
  • f

    frydim1

    05/17/2023, 5:29 PM
    should be changed if workers are going to run before a page rule
  • u

    Unsmart | Tech debt

    05/17/2023, 5:29 PM
    They dont run before a page rule they just run before cache
  • i

    Isaac McFadyen | YYZ01

    05/17/2023, 5:29 PM
    Bindings are user-specific: sockets are not.
  • c

    Chaika

    05/17/2023, 5:29 PM
    Workers don't run before page rules. They run at the end, in their position
  • c

    Chaika

    05/17/2023, 5:30 PM
    It's just that all the page rule cache does is set a variable internally "ok, cache everything", but caching itself is an operation that runs in the origin part, after Workers
  • c

    Chaika

    05/17/2023, 5:31 PM
    If you use a page rule to change security level, same thing, it's not like at the moment it quits early to respect your override. It just sets it to be used later
  • f

    frydim1

    05/17/2023, 5:34 PM
    well at the moment is not worth using workers that way, sadly
  • t

    Tom Sherman

    05/17/2023, 5:41 PM
    I think the decision is more important to think about in terms of being standards compliant Adding things to the global scope is a huge risk because it can web block standards from progressing
  • k

    kian

    05/17/2023, 5:43 PM
    My original thought was non-standards shouldn’t be in the global scope - but I guess there’s HTMLRewriter and WebSocketPair which benefit from having a name that isn’t likely to conflict with future proposals.
  • d

    dave

    05/17/2023, 6:03 PM
    is this new?
  • i

    Isaac McFadyen | YYZ01

    05/17/2023, 6:05 PM
    Not really. The way
    workerd
    works is that they put everything shared across every Worker (such as
    fetch
    , all global APIs like HTMLRewriter, etc) into an isolate and then freeze a "snapshot". Then when a user sends a request to their Worker, they "thaw" the snapshot (which is the same across all users) which helps prevent cold-start delays. However, this doesn't work with user-specific bindings - since the bindings are not the same across Workers, if they wanted to put them in the global scope they would need to "thaw" the common snapshot, add the globals, and then continue, which adds some extra cold-start duration. That's one of the purposes of Module Workers - they avoid the need for user-specific global code.
  • s

    sathoro

    05/17/2023, 6:29 PM
    struggling with something that seems so simple...
  • s

    sathoro

    05/17/2023, 6:29 PM
    how to fetch
    image/png
    response and get a base64 version of it?
  • k

    kian

    05/17/2023, 6:32 PM
    There’ll be plenty of examples on SO to turn ArrayBuffers into base64 - you can get the ArrayBuffer with await response.arrayBuffer(). If you want a Data URL with that then it’ll be a little different.
  • w

    Walshy | Pages

    05/17/2023, 6:33 PM
    Buffer.from(arrayBuffer).toString('base64') With nodejs_compat compat flag
  • s

    sathoro

    05/17/2023, 6:34 PM
    it worked 😻 I tried several other things first that didn't work lol
  • s

    sathoro

    05/17/2023, 6:35 PM
    playing with Stability.ai's new model...
  • s

    sathoro

    05/17/2023, 6:43 PM
    can you not upload an image to Cloudflare Images directly? it seems to require a URL?
  • d

    dave

    05/17/2023, 8:06 PM
    anyone else having trouble uploading a Worker?
1...247224732474...2509Latest