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

    geelen

    12/02/2021, 4:49 PM
    Ah sorry, no there isn't. There will be some mechanism for excluding requests from your Functions/Worker for GA launch, but we don't know exactly what that'll look like yet.
  • g

    geelen

    12/02/2021, 4:49 PM
    Service worker crawling HTML is a good use-case to exclude from that traffic, though, I'll keep that in the back of my mind
  • w

    wonkrattle

    12/02/2021, 5:02 PM
    Yeah especially since that content could be very much out of date or inaccurate By the time it is accessed
  • g

    geelen

    12/02/2021, 5:20 PM
    what do you mean?
  • w

    wonkrattle

    12/02/2021, 5:58 PM
    So for example, I have a function that rewrites the homepage to display the current weather in your location: https://www.chrisfnicholson.com
  • w

    wonkrattle

    12/02/2021, 6:00 PM
    So if that page was later loaded offline by a worker, the data would almost certainly be incorrect.
  • w

    wonkrattle

    12/02/2021, 6:01 PM
    And I’m sure there are plenty of other use cases that run into the same issue
  • g

    geelen

    12/02/2021, 6:30 PM
    right but that sounds like a downside of pre-caching all this data in a service worker, right?
  • g

    geelen

    12/02/2021, 6:30 PM
    nothing to do with the Pages Function itself, is it?
  • s

    Shyamin

    12/02/2021, 7:21 PM
    I tried same for MailJet but it's not working on production
  • s

    Shyamin

    12/02/2021, 7:55 PM
    can you show me your code ?
  • j

    Jeremiahlee

    12/02/2021, 8:17 PM
    Sure, did a quick edit and posted here https://gist.github.com/jeremiahlee/c4c9c54fc4dd66c74e61ff4c3f65025c
  • s

    Shyamin

    12/02/2021, 8:18 PM
    Thank you very much ... 😊
  • w

    wonkrattle

    12/02/2021, 8:29 PM
    No because the website is otherwise static. The dynamic data is being generated by the function. So, absent the function, it’s not a problem to cache an older version of the website, because it just might be missing some more recent posts.
  • g

    geelen

    12/02/2021, 8:34 PM
    But couldn't you just set the service worker not to cache any of your dynamic routes?
  • w

    wonkrattle

    12/02/2021, 8:35 PM
    No, because then the homepage wouldn’t load if you were off-line
  • w

    wonkrattle

    12/02/2021, 8:37 PM
    I’m using HTMLrewriter to update content on the homepage
  • w

    wonkrattle

    12/02/2021, 9:23 PM
    But yeah that would be fine if the entire route was dynamic
  • e

    Erwin

    12/02/2021, 11:57 PM
    You have full control over what and how you download things in your serviceworker. So you could always try to refresh a particular URL and only fall back to the downloaded one if you aren't online.
  • j

    jacobmarble

    12/03/2021, 12:00 AM
    Good afternoon. My deployment build fails with a large javascript file in /functions.
    Copy code
    15:27:38.648    Compiling worker to "/opt/pages/functions/user-worker.js"
    15:27:38.751    Finished in 607ms.
    15:27:38.759    Validating asset output directory
    15:27:40.471    Deploying your site to Cloudflare's global network...
    15:27:58.448    Failed: an internal error occurred
    I can cause this to go away by omitting the large file. What is the file size limit? The large .js file in question is about 350kB, generated by webpack.
  • w

    whatnickdiscords

    12/03/2021, 12:42 AM
  • w

    whatnickdiscords

    12/03/2021, 12:43 AM
    This reads a little funky. Does this just mean "will be included in the bundled plan" or double dipping here $5 for bundled + $5 for functions?
  • w

    whatnickdiscords

    12/03/2021, 12:43 AM
  • w

    whatnickdiscords

    12/03/2021, 12:44 AM
  • w

    whatnickdiscords

    12/03/2021, 12:49 AM
    For example, the paid plan has 100 script limit. Does that mean each
    functions/route/file.js
    is a script?
  • w

    whatnickdiscords

    12/03/2021, 12:50 AM
    Almost makes sense to just run your own router. That would be quite expensive on any serious app
  • w

    whatnickdiscords

    12/03/2021, 12:51 AM
    @User 👋
  • e

    Erwin

    12/03/2021, 12:54 AM
    Oh no.. all your functions are compiled into 1 script. And with the pricing I am pretty sure they mean the price/request, not the initial $5.
  • e

    Erwin

    12/03/2021, 12:55 AM
    The limit has always been way more than 350KB.. it was 1MB and is 5MB now in certain circumstances I think?
  • j

    jacobmarble

    12/03/2021, 12:55 AM
    Hmm.
1...272829...392Latest