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

    Deleted User

    03/02/2022, 1:25 AM
    does CF cache fetch requests automatically? say I want to retrieve json from an API once per week and then store the response on the edge servers for a week
  • d

    Deleted User

    03/02/2022, 1:25 AM
    how 🙂
  • d

    Deleted User

    03/02/2022, 1:26 AM
    the docs talk about it but I'm not fully clear regardless
  • d

    Deleted User

    03/02/2022, 1:27 AM
    additionally can you do these in pages functions? https://developers.cloudflare.com/workers/runtime-apis/scheduled-event/ could I use a "scheduled event" to do the fetch so page load speed isn't affected when the cache is empty
  • d

    Deleted User

    03/02/2022, 1:28 AM
    it looks like cron triggers are set up in the CF dashboard and then
    waitUntil
    is somehow useful...
  • d

    Deleted User

    03/02/2022, 1:30 AM
    maybe it's best to build this into my static site generator and run the build regularly with a Github Action or something instead
  • d

    Deleted User

    03/02/2022, 3:37 AM
    I've got it: https://developers.cloudflare.com/workers/examples/cache-api/ genius. now I understand waitUntil
  • n

    Noel Jacob

    03/02/2022, 6:04 AM
    where is cf in sveltekit endpoints?
  • a

    alinador

    03/02/2022, 12:40 PM
    Hi guys, If we want to change html templates based on custom logic, is there a way in function to do context.next and pass different route without redirecting?
  • a

    alinador

    03/02/2022, 12:44 PM
    we want to have the same behaviour as transform rules (url rewrite)
  • i

    Isaac McFadyen | YYZ01

    03/02/2022, 1:05 PM
    CF should be on Request in SvelteKit endpoints.
  • r

    richardcooke

    03/02/2022, 3:24 PM
    Every now and again we're see "worker exceeded resource limits" which I think is because we're exceeding the 50ms execution time, is it possible to use unbound workers with pages functions?
  • a

    alinador

    03/02/2022, 4:09 PM
    Very good question - I would like know it as well
  • j

    justinhook

    03/02/2022, 8:13 PM
    Posting my third Pages issue here since it's related to functions: I always have this error that I've exceeded my Functions limit, but I don't use functions. (I'm not sure when this resets exactly but it seems like it pretty much just sits at 105k - thats always around where I see it.)
  • i

    Isaac McFadyen | YYZ01

    03/02/2022, 8:14 PM
    Do you use SvelteKit, Remix, or Flareact?
  • i

    Isaac McFadyen | YYZ01

    03/02/2022, 8:14 PM
    A lot of tools use Functions in the background, including those three.
  • j

    justinhook

    03/02/2022, 8:18 PM
    Hmm I do not. And the functions section of my Pages settings has no functions in. it.
  • j

    justinhook

    03/02/2022, 8:21 PM
    I use firebase and gatsby, but gatsby should only run at build and firebase is handled elsewhere.
  • z

    zsmooth

    03/02/2022, 9:47 PM
    No, it is not possible currently. I was told by support this may change. It’s one thing that forced me onto Worker Sites instead of Pages.
  • a

    alinador

    03/03/2022, 10:41 AM
    thanks for the reply
  • m

    minimusubi

    03/04/2022, 5:02 AM
    Regarding functions routing, is there a way to get this endpoint to work without using [[anyDepth]]? For example, the file structure
    /api/user/[foo]/[bar]/id.ts
    does not seem to map to
    /api/user/*/*/id
    (404 not found) I would prefer not use use the double square brackets, as this would allow any path depth
  • g

    geelen

    03/04/2022, 9:57 AM
    hmm, i'm surprised that doesn't work...
  • g

    geelen

    03/04/2022, 9:58 AM
    On a recent deployment, if you go to the
    Functions
    tab, you should see a
    Configuration
    section
  • g

    geelen

    03/04/2022, 9:59 AM
    that's not super human-readable yet (we're working on that) but maybe paste that here so I can see what the Functions compiler is seeing?
  • m

    minimusubi

    03/04/2022, 10:12 AM
    I should add that I'm testing this with wrangler2 beta and that I have not tried an actual deployment to functions. I can try that and get back to you
  • m

    minimusubi

    03/04/2022, 11:32 AM
    I'm trying to deploy my pages site with functions, and I'm getting this error during deployment.
    Copy code
    01:08:25.042    ✘ [ERROR] Could not resolve "realm-web"
    01:08:25.042    
    01:08:25.042        ../../../buildhome/repo/functions/util/mongo.ts:1:23:
    01:08:25.042          1 │ import * as Realm from 'realm-web';
    01:08:25.042            ╵                        ~~~~~~~~~~~
    01:08:25.042    
    01:08:25.042      You can mark the path "realm-web" as external to exclude it from the bundle, which will remove this error.
    Is this an issue with the location of my
    functions
    directory? The general project structure looks like this
    Copy code
    /functions
      - /utils/...
      - /api/...
    /public
      - index.html
    /package.json
    and I've set
    /public
    as my build output directory
  • g

    geelen

    03/04/2022, 1:18 PM
    what's your build command?
  • m

    minimusubi

    03/04/2022, 2:38 PM
    ive left that empty since the pages themselves are just static for now. is that the issue?
  • g

    geelen

    03/04/2022, 6:10 PM
    ah yep
  • g

    geelen

    03/04/2022, 6:11 PM
    it won't run
    npm install
    without a build command
1...888990...392Latest