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.
randomValue = SysInfo(10)
C = URLServer & "recipeshopHelp/RecipesHelp.txt?" & randomValue
req=ReadFile(C)
If req.status=200 Or req.status = 0 Then
ServerRecords = req.responseText
localStorage.setItem("tblRecipesHelp",ServerRecords)
Else
M = C & " not found."
Call ShowMsg(M,0,"Updating Settings") 'ShowMsg() is my internal function not part of App Studio basic
End If
The randomValue is used to fool the browser into not using a cached file.
However it seems to me that these 2 bits of code have different purposes.
The first is looking for version.txt file when the app is disconnected from the net. A PWA should find this file but it is not finding it.
The second is not off line but making sure the file is down loaded rather than the local file being used.
My problem is that in the first case where the file is not found when off line but it should be for a PWA.