Execute worker only 1 time per session

Hi There,

I am trying to get geo location of users without using my server,

So to get geo location from cloudfalre worker by useing - request.headers.get(‘Cf-Ipcountry’)

Since workers is feature billed per usage I am trying to figure how to execute the workers only when we need it to run.

Basically we don’t need it to run every pageviews and only once per session,

Is there any way to serve the worker only once per session?

I don’t mind writing client side in order to make it work…

You should perform a single request to the worker, limiting it to run on the specific path you are interested. The worker runs once per request on each path that you enable it on.

2 Likes

like Matteo said, one option I think of is to make the worker only run on some unique url, and call that url with ajax once per session