Clarify nocache parameter of HttpService.GetAsync

On the HttpService.GetAsync page, it is claimed that the nocache parameter is used to control caching of requests made with the same URL. In practice, nocache==false appears to behave no differently from nocache==true.

The following code repeats a request to the same URL four times, receiving random bytes as a response:

for i = 1, 4 do
	print(i, game.HttpService:GetAsync("https://httpbin.org/bytes/8", false))
end

The result is that four different random strings are received, despite nocache being set to false.

Whether nocache is no longer respected, or there are certain conditions required for caching to occur, this behavior is not adequately documented. It may also just be a regression.

3 Likes

When nocache is true, the Cache-Control header is set to no-cache in the request. It’s up to the requested site to do the caching and allow you to bypass their CDN. This is primarily a hold-over from when GetAsync didn’t accept a headers parameter when it was originally released.

I’ll make a note to update this page to include this more detailed explanation.

1 Like

Cache-Control has no-cache regardless of the parameter.

> print(game.HttpService:GetAsync("https://httpbin.org/headers", false))
{
  "headers": {
    "Accept": "*/*", 
    "Accept-Encoding": "gzip, deflate", 
    "Cache-Control": "no-cache", 
    "Host": "httpbin.org", 
    "Roblox-Id": "12345678", 
    "User-Agent": "RobloxStudio/WinInet"
  }
}

> print(game.HttpService:GetAsync("https://httpbin.org/headers", true))
{
  "headers": {
    "Accept": "*/*", 
    "Accept-Encoding": "gzip, deflate", 
    "Cache-Control": "no-cache", 
    "Host": "httpbin.org", 
    "Roblox-Id": "12345678", 
    "User-Agent": "RobloxStudio/WinInet"
  }
}
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.