https://discord.cloudflare.com logo
Join Discord
Powered by
# functions
  • i

    Isaac McFadyen | YYZ01

    02/17/2022, 2:01 PM
    Oh, cheaper?
  • i

    Isaac McFadyen | YYZ01

    02/17/2022, 2:02 PM
    Someone needs to make a calculator for these things... hmmm....
  • e

    Erwin

    02/17/2022, 2:10 PM
    Break even point between Bundled and Unbound is average wall clock time of 225ms
  • i

    Isaac McFadyen | YYZ01

    02/17/2022, 2:10 PM
    Oh, really! Wow, Unbound it is then 😆
  • g

    geelen

    02/17/2022, 2:11 PM
    40ms cpu time? What are you rendering?
  • i

    Isaac McFadyen | YYZ01

    02/17/2022, 2:11 PM
    SvelteKit right now. Let me confirm those are the stats for my Functions (I'm getting them from the email I get every week that shows me increases in times; I can't find them anywhere else).
  • i

    Isaac McFadyen | YYZ01

    02/17/2022, 2:12 PM
    Hmm... it really fluctuates actually (I was wrong with that 40ms number), between 20ms and 12 but not below 10.
  • i

    Isaac McFadyen | YYZ01

    02/17/2022, 2:12 PM
    And that doesn't show clock-time.
  • g

    geelen

    02/17/2022, 2:13 PM
    ah yeah for the moment you won't be able to see any stats easily within Pages, you can try to deploy the same code with Wrangler to a normal worker
  • t

    toitao

    02/17/2022, 2:13 PM
    Hello, is there a way to see logs from page functions? already ansered :=)
  • k

    Kedas

    02/17/2022, 3:18 PM
    I'm working on a svelte app with pages and functions, the app itself is completely static and it should be a single page. I have endpoints where that page should be served but with some metadata. Is there any way to have middleware on those endpoints that replaces a placeholder in the static file?
  • i

    Isaac McFadyen | YYZ01

    02/17/2022, 3:18 PM
    Sort of? You can use the
    adapter-static
    with SvelteKit, then have manual functions to intercept requests to the static files.
  • i

    Isaac McFadyen | YYZ01

    02/17/2022, 3:19 PM
    Oh wait, just Svelte? Not SvelteKit?
  • k

    Kedas

    02/17/2022, 3:19 PM
    well I'm using sveltekit with adapter static
  • i

    Isaac McFadyen | YYZ01

    02/17/2022, 3:20 PM
    Ok, then yes. Functions are what you probably want. The Function will intercept the request, then you call
    await next()
    to get the static file, then you can run HTMLRewriter to replace things.
  • i

    Isaac McFadyen | YYZ01

    02/17/2022, 3:20 PM
    One sec...
  • i

    Isaac McFadyen | YYZ01

    02/17/2022, 3:20 PM
    https://developers.cloudflare.com/pages/platform/functions#writing-your-first-function
  • k

    Kedas

    02/17/2022, 3:20 PM
    ah, thanks, that's exactly what I was looking for
  • i

    Isaac McFadyen | YYZ01

    02/17/2022, 3:20 PM
    That shows you how to get the static file (call
    await next()
    ).
  • i

    Isaac McFadyen | YYZ01

    02/17/2022, 3:21 PM
    Then you can use https://developers.cloudflare.com/workers/runtime-apis/html-rewriter to rewrite.
  • k

    Kedas

    02/17/2022, 3:21 PM
    yeah I should probably read the docs a little more thoroughly 😅
  • i

    Isaac McFadyen | YYZ01

    02/17/2022, 3:21 PM
    🙂 no problem!
  • i

    Ishan

    02/17/2022, 4:49 PM
    Uhh what do you render?
  • i

    Isaac McFadyen | YYZ01

    02/17/2022, 4:49 PM
    SvelteKit site.
  • i

    Ishan

    02/17/2022, 4:49 PM
    Oh
  • i

    Ishan

    02/17/2022, 4:49 PM
    My remix site takes like around 8-9ms cpu time
  • m

    Marcelino Franchini

    02/17/2022, 7:06 PM
    How do you get 0.225 seconds? This gives me a similar result: 1000000/(0.50−0.15)/(1000000/12.50/0.128/0.050) ~= 0.229 seconds Now that a Worker can be evicted after the response headers are sent, Workers Unbound seems more convenient for every scenario, what is still the raison d'être of Workers Bundled?
  • e

    Erwin

    02/17/2022, 9:06 PM
    And your math seems correct. Just rounding it to an easier to remember number. And Bundled is based on CPU time, so still better for slower origins.
  • c

    CrownedHead

    02/18/2022, 12:37 AM
    I'm at a little bit of a loss on how to get durable objects setup with functions. The docs don't seem very clear. I've setup a wrangler.toml in the root of my project to setup the bindings but no luck.
  • g

    geelen

    02/18/2022, 10:00 AM
    you have to set up the bindings in the project config in the Dashboard UI
1...777879...392Latest