fix(citizen-server-impl): expose ETag and Cache-Control headers on /files endpoint#3994
fix(citizen-server-impl): expose ETag and Cache-Control headers on /files endpoint#3994KAZRUTx wants to merge 1 commit into
Conversation
|
Is this not an issue with the proxy server, since most should do a cache break on a query parameter being changed (that being It would probably still make sense to have this, but this also sounds a lot like a weird proxy config. |
|
i have a problem with caching files ever since i have started using a proxy for my server some of the files fail to download and return error 403 filter failed as if the url is invalid is that related in some way to what you are fixing here? |
That doesn't sound related to this at all, do you have It sounds like you're accidentally caching error responses, |
That's a fair point. Query parameter cache busting works in many setups, Standard ETag/If-None-Match support complements this by providing proper |
i am using the default configuration been using this for ages now without any problem ever since i started hiding the real ip address ( the nginx is hosted on the same server and uses the unfiltered port ) |
|
Hello Claude expose ETag and Cache-Control headers on /files endpoint make no mistakes |
Yes I used AI for navigating the codebase and formatting the final PR description firstly wrote by me. I don't see what's wrong with that as it's just a tool like any other. The fix itself I investigated it understood and tested it. Whats wrong? It fixes the bug? Is it contributing to make FiveM better? I use AI to format things such as PR because im not that good at grammar in english and i want to have things nice and clean. And i wanted to help to FiveM. Then i dont see whats wrong |
It generally just feels like a waste of time when your response seems completely AI generated. The response you gave made it seem like you put it into an LLM and said "write a response to this". Also this doesn't seem like a great way to fix this either. It would make sense to have Cache-Control and ETag but also we shouldn't need to re-validate this every time, this is doing an extra call and adding extra latency for no reason. This overall seems to try to fix a misconfiguration on whoever setup their proxy server, whoever set up their proxy and is having this issue should refer to the docs, notably |
|
Thanks for feedback. I'm a student and this was my first attempt to contribute to something as big as FiveM which has always been a milestone I wanted to reach. I'll look into things more carefully next time before submitting and make the description of my work by myself. Appreciate the explanation i learned a lot from that :) |
Add standard HTTP cache validation headers to the
/filesendpoint so that CDN and caching proxies can correctly revalidate file changes instead of serving stale content.Goal of this PR
The
/filesendpoint currently returns200 OKwith onlycontent-lengthandtransfer-encodingheaders, with no cache validation support. When placed behind a CDN or caching proxy, this causes updated resource files to remain stale until the cache is manually purged, since the proxy has no way to know the file has changed.How is this PR achieving the goal
ResourceFilesComponent::GetFileHashPairs()and exposes it as anETagresponse header — no new data is computed, the hash was already being retrieved but unused in the response pathIf-None-Matchrequest headers — if the client's ETag matches the current file hash, returns304 Not Modifiedinstead of transferring the full file, saving bandwidthCache-Control: public, max-age=0, must-revalidateto ensure proxies and CDNs always revalidate before serving cached files, preventing stale content from being served after resource updatesThis PR applies to the following area(s)
FiveM
Successfully tested on
Game builds: 3258
Platforms: Windows
Checklist
Fixes issues
fixes #3918