Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to force QWebPage to store objects with no-cache in their response headers?



  • I'm writing a Qt program to load a webpage. Meanwhile, I want to store all the resources of the page (images, css, javascript). So, I did something like this:
    @QwebPage webpage;
    QNetworkDiskCache* diskCache = new QNetworkDiskCache(this);
    diskCache->setCacheDirectory("batch");
    webpage.networkAccessManager()->setCache(diskCache);@

    But the problem is that the first page of most of the websites come with "Cache-Control: must-revalidate" or "Pragma: no-cache" in their response headers. In these cases, QWebPage will not save the corresponding object in the cache directory. I was wondering if there is a way to bypass this and force the Qt to save all the objects in its cache regardless of those response header fields?


Log in to reply