-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Experiment with Qt HTTP caching options #1012
base: master
Are you sure you want to change the base?
Conversation
@@ -57,34 +55,6 @@ AssetClient::AssetClient() { | |||
this, &AssetClient::handleNodeClientConnectionReset); | |||
} | |||
|
|||
void AssetClient::initCaching() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more info below, but for some reason, it seems like we were only setting up caching for this AssetClient, not for all other requests? this code moved to NetworkAccessManager::getInstance()
@@ -58,7 +58,7 @@ void HTTPResourceRequest::doSend() { | |||
networkRequest.setHeader(QNetworkRequest::UserAgentHeader, NetworkingConstants::VIRCADIA_USER_AGENT); | |||
|
|||
if (_cacheEnabled) { | |||
networkRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache); | |||
networkRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should theoretically fix the cachebusting issue, see the docs for more info: https://doc.qt.io/qt-5/qnetworkrequest.html#CacheLoadControl-enum
QNetworkDiskCache* cache = new QNetworkDiskCache(); | ||
cache->setMaximumCacheSize(MAXIMUM_CACHE_SIZE); | ||
cache->setCacheDirectory(cacheDir); | ||
networkAccessManager->setCache(cache); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
according to the docs: https://doc.qt.io/qt-5/qnetworkaccessmanager.html#setCache
"QNetworkAccessManager by default does not have a set cache."
so...I think we were forcing PreferCache above, but then...not actually setting up a cache? hopefully this new code is more correct and more performant
So originally when we discussed cachebusting the idea was turned down because of concerns about web servers being set up properly to support that feature. |
This is implementing I think exactly what we were talking about. Webservers do have cache information in them, but currently we do not respect that. This gets us a bit closer to respecting that where possible. |
yeah I think this is a pretty standard feature? this PR basically amounts to “use more default Qt values, and use them more correctly” |
The following links are available: build (ubuntu-18.04, full)
build (windows-latest, full) build (ubuntu-18.04, android) |
Seems to work. A refresh button would definitely be useful. I uploaded a model,then modified is slightly in blender, reuploaded to my S3, then removed the link and repasted and the model. The updated model appeared without cache-busting. |
One way to do this would be to have the refresh button empty the field and then paste back in the URL quickly (hacky method). The other method might be to have an actual scripting API call that allows you to just trigger a reload for a resource. Given that the system handles that pretty well... It's possible that multiple parts of the system are looking at the URL for a change, but I'm hoping that it's simply the case that the resource being refeteched would update all layers. As for falling out of sync with others, it can send a message for others' Create app's to do the same call on that model? |
yeah for now the best way to do this would be to set the URL to "" and then set it back to the actual URL, just to make sure everything picks up on the change. we might just need to copy how it works for the script field? someone who understands create more than me might need to take that over |
Theoretically you could lose the URL if the reload button removes the URL and adds it back. On Linux this happens often enough. |
Note: In the Create app, the client script and server entity script fields both have a "reload" button. |
ok added a reload button, ready for testing |
The following links are available:
build (macOS-latest, full) build (windows-latest, full) build (ubuntu-18.04, android) |
Refresh seems to work, but its worth noting the the new object will retain the dimensions or the original (reset dimensions will correct this). This is not a bug, and is desirable in many cases, but worth considering in the future. |
Is there any way to make downloads work even if links redirect? I'm not sure how the system works or how things like that work in general. However, between caching improvements and redirecting users to downloads that are on edge servers I think we can get fast loading times. |
My understanding is that, load times should be same or worse. Old behaviour is to just never update the cache. So whatever you downloaded would not change even if the source file changed. My understanding is that this PR contacts the server to find out if the cache is outdated. |
The following links are available: build (ubuntu-18.04, full)
build (windows-latest, full) build (ubuntu-18.04, android) |
Test with webserver caching options set to no cache... |
So, I've found that the refresh button doesn't update for file:/// or https:// cases, did not try others but basically I see the model blink as if it's reloading except the new model doesn't show up. I test this by...
However, the test for cachebusting in general worked successfully...
I do not believe my caching options on the webserver affected either case much. |
hmmm how is that different than what @Aitolda tried originally and reported success for? |
So I finally got to digging into this again and now I'm simply confused. I tried the newest version of this PR and couldn't get it working, so I started backtracking all the way to the first release on Feb 9, which was on the old protocol and it worked suddenly. Got excited, tried again, and it didn't work. Frustrated, I tried again and this time it worked. Seems to be inconsistent. Here's what I've been doing. I have two models that are both simply named "cube.glb" One of these is rotated off axis. Next I replace the original file on my S3 with the alternate cube.glb. Again so far I've only got this working on the original Feb 9th version but it's worth trying the others again. Will keep investigating. |
Going by Aitolda's comments it seems this needs more testing still |
The following links are available: build (macOS-latest, full) build (ubuntu-18.04, full)
build (windows-latest, full) |
Hello! Is this still an issue? |
potentially closes #92 and #990
fixes #1062
should theoretically
also adds a reload button next to model URL in create
Test plan/open questions: