简体   繁体   English

防止Corona缓存我的网络请求

[英]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. 我在文档中找不到任何有关资源缓存的信息,但是从我的测试看来,Corona缓存的文件不是我想要的。

-- 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. 作为一名Web开发人员,我习惯于处理浏览器的缓存恶作剧。 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 归功于ldurniart ,看来

Cache-Control: no-cache

to the header forces the system to disregard the cache, though it ultimately depends on the system to decide. 尽管最终取决于系统来决定,但对标头的强制会迫使系统忽略高速缓存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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