Skip to content

How to serve a static file directory with uWS #997

Closed

Description

@JemiloII

So for this next project I'm doing, I really want to use uWS for https and wss. Most of my projects have the two split unfortunately. This project is much simpler but I don't see how with uWS to serve static content. I don't want to have to make a wildcard and do file lookups. I just want a simple thing like express, where I just do .static(route). I have a couple image directories, audio directory, and an angular build dir I want to make static. Does uWS have a simple way of doing this?

Activity

  1. uNetworkingAB commented on Dec 9, 2023

    @uNetworkingAB
    Contributor

    No but it could possibly be done at some point, maybe.

  2. Dxig commented on Dec 11, 2023

    @Dxig

    Why not using Nginx for static files?

  3. nickchomey commented on Dec 13, 2023

    @nickchomey

    Why not cloudflare cdn? They also have websockets support among plenty of other things

  4. dalisoft commented on Dec 13, 2023

    @dalisoft

    @JemiloII You can look at here for ways to serve file/directory. Or use Cloudflare CDN as suggested by @nickchomey

  5. JemiloII commented on Dec 13, 2023

    @JemiloII
    Author

    Can't use cloud flare as a cdn, my website generates images and other content. It would be too slow to upload to a cdn and then serve. Faster to just serve from the server.

    I don't want to use ngnix to serve static files. I just want to use uWS. I don't want to mess with proxies, on a server instance just to serve content on port 80/443. For my experience with Cloudflare, it doesn't play nice with sockets on other ports if you're not a pro member. Even as a pro member, the sockets for my use cases when proxies perform better on those ports.

  6. nickchomey commented on Dec 13, 2023

    @nickchomey

    I think you're misunderstanding a cdn. If you proxy your dns through cloudflare, it will automatically cache all static assets when requested and serve those automatically to future visitors. Not only that, but it gets served from "the edge" - their 300+ datacenters that are much closer to your visitors than your server will be.

    Html needs to be specifically selected for caching though - they have docs on it.

    They also offer Cloudflare Pages for static sites. It might suit your needs.

  7. uNetworkingAB commented on Dec 24, 2023

    @uNetworkingAB
    Contributor

    App.static(path) could definitely be a feature to look at some point but not right now. uWS doesn't exist where it doesn't provide exceptional value, and so if it would have app.static, it would have to be one of the best performing such features. Right now, that's not the case, since it would require kTLS and sendfile which would lock it to Linux only, which is not the plan. So it's more than just an opinion - I don't want to add features which aren't obviously motivated. Esp. not since most companies use proxies and proxies have static file serving built-in

  8. locked and limited conversation to collaborators on Dec 24, 2023
  9. converted this issue into a discussion #1003 on Dec 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions