4 ms·
Are there any plans to provide browser detection in the worker API? I imagine it's possible to implement as a user now, but may be clunky to provide a dataset t
by mbell 8y ago
Are there any plans to provide browser detection in the worker API? I imagine it's possible to implement as a user now, but may be clunky to provide a dataset to work from. This seems like a killer feature to have on edge workers to allow serving optimized builds for based on browser feature support without paying the overhead of client side detection.
- zackbloom 8y agoIf you can find a good Javascript library for doing it you can build it into your Worker with Webpack.
- mbell 8y agoIt's not finding a parser that I find problematic, it's the dataset needed. My understanding is that the workers are limited to 128MB of ram and that they may be 'restarted' at any time. Datasets for accurate browser detection would be really tight in fitting into that amount of RAM when combined with whatever else you may be doing and you have to deal with load / parse time whenever a worker is restarted. This seems like a common enough need that cloudflare could provide it as an API and their implementation wouldn't have such issues.
- kloepper 8y agoUsing storage along with worker code to perform the function should make this possible. Our hope is that anyone could create such an API, not just Cloudflare. Just like we are building storage on top of workers, we hope to eliminate the distinction between what is possible for a Cloudflare employee and what is possible for any of our customers.
- elithrar 8y ago> ... understanding is that the workers are limited to 128MB of ram and that they may be 'restarted' at any time. Datasets for accurate browser detection would be really tight in fitting into that amount of RA I think you might be overestimating that. Bundling the aforementioned https://github.com/faisalman/ua-parser-js https://github.com/faisalman/ua-parser-js wouldn't be significant - maybe hundreds of KB as a script (distinct from memory!) - at most.
- manigandham 8y agoThe only browser detection possible on the server-side is with the user-agent and other headers, which you already have access to within Workers. You can parse that string reliably for modern browsers, and have a fallback for the rest. No big dataset needed, just some regex and if/then statements. If you still want a library then you can try https://github.com/faisalman/ua-parser-js https://github.com/faisalman/ua-parser-js