Optimizing resource downloads using a caching proxy

Fivem successfully trying to download file server but getting ‘Unkown Error’ and cant download the file.

feel free to share how you do it… having hard time running server behing nginx reverse proxy…

hi ijijiojoij

When I use this scheme, after setting up nginx, but it will not create a cache, just an empty file, I can’t see the error from the log, can someone provide a better solution?

1 Like

its not possible because this only support nginx

1 Like

yeah, totally (this does not use UDP proxy so would be fine)

Hi !
I have this issue with this method:

Loading resources stopped here.
One idea ? ^^

what is the advantage to doing this? Is it to move server side cashe? If so what is the the point? I am sure that there is a good reason to do it but I cant understand. lol.

Saves I/O generated by FXserver and data transfer over HTTP if running on external server.

1 Like

Hey man, its really urgent! Did you fix it?

Got my server online rn and many people try to join, but getting the exact same errors like you

1 Like

Sorry but no, i’ve trying apache2 when i have this error, now i’m on nginx with configuration from this post and all work, just the first caching is tooooo long :confused: (~1h30 for 2Go…)

1 Like

Could you send your config in here?

proxy_cache_path /srv/files levels=1:2 keys_zone=assets:20M max_size=10g inactive=7d use_temp_path=off ;
log_format asset '$remote_addr - [$time_local] "$request" $status $body_bytes_sent $upstream_cache_status';

server {
        listen 80;

        location /files/ {
                aio threads;
                directio 5k;
                access_log /var/log/nginx-access.log asset;
                error_log /var/log/nginx-error.log;
                add_header X-Cache-Status $upstream_cache_status;
                proxy_cache_lock on;
                proxy_pass http://ip_of_my_server:30120$request_uri;
                proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
                proxy_cache assets;
                proxy_cache_valid 1y;
                proxy_cache_revalidate on;
                proxy_cache_min_uses 1;
                proxy_cache_key $request_uri$is_args$args;
        }
}

3 Likes

And in my server cfg at the end:

# Remove the file server associated with a resource regex.
fileserver_remove ".*"
# Set the file server for the specified resource regex.
# The URL should *not* end with a slash.
fileserver_add ".*" "http://adress_of_my_cache_server/files"

# List all registered file server patterns.
fileserver_list

to verify if the url is good in the server you can type the command fileserver_list to show that:

.* -> http://address_of_your_cache_server/files
1 Like

So has your problem been solved?

If proxy cache has been unreachable you also can execute the firs command from server cfg:

fileserver_remove ".*"

This deactivates the use of the proxy cache, the time to repair it, the fx server will send the files itself, which at least does not “block” the game on the server.

you don’t need to add “upstream backend {}” in this conf?

No it’s not necessary in my config because the proxy_pass directive is used to set endpoint of reverse proxy.

Thank u! there’s another pending reply i’ve sent, i list my questions in it. thank you for your time! :smile:

Dear Gyzzmo,
thank u for sharing, quick question here:
1.how do you know when cache is began?
2.how did you find out the caching took ~1h30 for 2Go in post#33 ?
3.did u start the docker service like this post did? what dose it work?
4.we’re getting same errors like you had in #post28 when we contact the veh mods with file{ police.ytd police.ytf } in manifest, it’s solved after we remove the “file{}”.
*major:*5.we’re experiencing timeout and package loss even nginx proxy service is running perfectly, we found out that resources is cached by nginx only when players loading them in ‘loading screen’, after they joined the server, fxserver will send the mods itself without caching proxy and bandwitdh was full everyones lagging(we didn’t remove the fileserver or tires any other cmds).

1 Like