How many Workers scripts can I have per domain?


#1

How can you store many scripts under the same domain?
Later with routing trigger individually.
Or will be the option just one big script pre domain?


Cloudflare Workers Beta Feedback
#2

Hi @adaptive, regular accounts are limited to a single script per domain, while enterprise accounts can have multiple scripts per domain.

The enterprise-level multi-script feature is useful to split up responsibilities among different teams, but using a single script per domain brings its own performance benefit: it’s less likely to be evicted due to infrequent use, so you are less likely to encounter cold starts of your script.


#3

So as someone who is new to Workers and similar products, would it be the best thing to write my own routing code if I want to trigger different functions based on subdomain and route?


#4

Hi @cat24max, yes, I’d say so. There exist routing libraries out there (e.g., ruta3) that you might want to experiment with if your needs end up being substantial. Otherwise, I’d recommend starting with a simple if-else chain, like in this example recipe: https://developers.cloudflare.com/workers/recipes/conditional-routing/

Harris


#5

Thanks, I have looked at ruta3, but I don‘t think it‘s really the best for my usecase.
I need to get the current subdomain AND route and then route the request to the correct function.
But it won‘t be alot at this time, so a do-it-myself routing is probably sufficient.