req=ReadFile(“myfile.txt”) used to work (Offlineapp.manifest) before going to PWAs with the ServiceWorker. With extraFiles containing the name of the text file upon a full deploy to the server this file can be seen in the Application/Cache Storage when running Chrome on a PC. It’s there along with all of the other picture files used by the app and those work properly when offline. Is there some other method to use for reading these cached files?
I’m trying to read a file when the Internet is offline, so reading a php script on the server cannot be accessed.
As stated, reading a file with ReadFile while offline worked in previous Offlineapp.manifest apps, now with PWA it does not work. Providing the full link to the server was also tried, but failed.
where hw is the name of the app deployed to the server.
Testing with AS sample HelloWorld with Button1 modified and property Make PWA? = True:
Function Button1_onclick()
'MsgBox "Thanks for clicking!"
C = "version.txt"
req=ReadFile(C)
'req=Ajax(C,"POST")
If req.status = 200 Or req.status = 0 Then
C = req.responseText
alert("got version.txt: " & req.status & ":" & C)
Else
alert("unable to get file")
End If
End Function
where version.txt is in extraFiles.
Deploy to server, run the app and the correct number in version.txt is returned with Button1_onclick.
From Chrome go to consol (F12) and select Application/Cache Storage and all of the cached files are there, including version.txt.
Select Network/offline. Press Button1_onclick and req.status is 0, not 200, and req.responsText is undefined.