Allow developers to manually clear cached web resources

As a Roblox developer, it is currently too hard or impossible to get up-to-date web resources after they have been cached on the server. It is possible to set up a workaround with HttpService or pulling information from clients, but this is tedious, and in the case of pulling data from the client, insecure.

Group ranks, in particular, are a major pain point for me. After the server requests the rank of a user in a group, it will never issue another request as long as the server is alive. This causes problems when games have special functionality for group members and you want to integrate groups closely with your game (e.g. factions). In addition to group information, there are lots of other web resources that are cached on the server as well, like PlayerHasPass whenever that gets enabled again.

I propose that Roblox consolidate the cache system into a CacheService and expose this cache to the developer. Internally, the old GetRankInGroup/IsInGroup/etc functions would work the same, but they would set their cache under a specific scope and key.

If you called GetRankInGroup, then the results of that call would be stored under CacheService internally. Then, if you wanted to to get up-to-date information, you could run CacheService:ClearGroupCache(groupId, userId) before issuing the method call again.

This pattern could be extended with more methods added to CacheService for each cache type, e.g., ClearAssetCache, ClearMarketplaceInfoCache, etc. I think that creating new methods for each type would be better than having a generalized Clear(scope, key) method because for cached items like GetRankInGroup, the key would be some arbitrary combination of the group id and user id, and remembering magic strings (or in this case, patterns) like this doesn’t feel good as a developer (Looking at you, SetCore).

I think that this solution is better than adding another parameter to the methods themselves to ignore cache or just disabling the cache outright, because in a lot of situations, the cache is actually favorable, both for the developer and Roblox. There are just some situations when it just gets in the way, so I think we should have a way to explicitly clear specific cached data. If Roblox feels that this will be too straining for the platform, I think this implementation could still work even if the frequency of the cache clears was limited even to once per minute per scope/key.

If Roblox is able to address your this issue, it would save me and a lot of other developers a lot of time by not having to develop long-winded workarounds just to get up-to-date data.

15 Likes

I totally support this. I have had to tell so many players that the issue they are having is because they need to join a new server. But when they leave the current server and go to join a new one, for small games they just end up back in the same server, especially if their friends are in it because Roblox joins players with their friends automatically. So they are sometimes forced to buy a VIP server or wait until the current server dies out. When testing updates I often find myself just shutting down all servers just so I know all caches are cleared and something about kicking players out of the game unexpectedly for such a simple issue just feels wrong. I hope this can be fixed soon.

3 Likes