简体   繁体   中英

Prevent Corona from caching my network requests

I couldn't find any information in the documentation that mentions resources caching, but from my tests it seems like Corona caches files which is not what I wanted.

-- if this file has been downloaded before, Corona will be happy to ignore it
-- for me
network.request(some_url, "GET", network_handler, {
    filename = some_file_name,
    baseDirectory = system.CachesDirectory
})

As a web developer, I am used to dealing with browsers' caching shenanigans. Applying the same fix seems to fix the issue:

network.request(string.format("%s?_=%d", some_url, os.time()), "GET", network_handler, {
    filename = some_file_name,
    baseDirectory = system.CachesDirectory
})

This is definitely not optimal but I couldn't find any useful information in the documentation. Caching also seems to only affect downloading files. Normal network requests are not affected.

Any ideas on how to disable caching properly?

Credit to ldurniart , it seems that adding

Cache-Control: no-cache

to the header forces the system to disregard the cache, though it ultimately depends on the system to decide.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM