Adds “Disable Response Caching” debug setting

When enabled, AltStore will ignore cached responses for certain requests and will always make a new request to the server. This is useful for development when repeatedly testing changes to remote files.

Limited to UpdateKnownSourcesOperation for now, but will eventually affect fetching sources as well.
This commit is contained in:
Riley Testut
2023-05-29 12:10:44 -05:00
committed by Magesh K
parent a38eba8449
commit 86ae06e0c8
4 changed files with 50 additions and 8 deletions

View File

@@ -30,11 +30,26 @@ extension UpdateKnownSourcesOperation
class UpdateKnownSourcesOperation: ResultOperation<([KnownSource], [KnownSource])>
{
private let session: URLSession
override init()
{
let configuration = URLSessionConfiguration.default
if UserDefaults.standard.responseCachingDisabled
{
configuration.requestCachePolicy = .reloadIgnoringLocalCacheData
configuration.urlCache = nil
}
self.session = URLSession(configuration: configuration)
}
override func main()
{
super.main()
let dataTask = URLSession.shared.dataTask(with: .sources) { (data, response, error) in
let dataTask = self.session.dataTask(with: .sources) { (data, response, error) in
do
{
if let response = response as? HTTPURLResponse