Bug 35633 - [Qt] Provide a way to directly invalide the page cache in a QWebPage
Summary: [Qt] Provide a way to directly invalide the page cache in a QWebPage
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Qt (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P3 Enhancement
Assignee: Nobody
URL:
Keywords: Qt, QtTriaged
Depends on:
Blocks:
 
Reported: 2010-03-03 02:59 PST by Tor Arne Vestbø
Modified: 2014-03-17 16:17 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tor Arne Vestbø 2010-03-03 02:59:07 PST
This bug report originated from issue QTBUG-8438
http://bugreports.qt.nokia.com/browse/QTBUG-8438

--- Description ---

Since Qt 4.6, there has been a QWebPage:: ReloadAndBypassCache page action. But it doesn't work when the page content has been set directly with QFrame::setContent, and the HTML used references (for instance) CSS files on disk. Even if those CSS files are changed after the page is loaded, triggering both Reload and ReloadAndBypassCache does not change the styles applied (the cache is used and the page doesn't see the changes).

<p>I'm not sure but I think the ReloadAndBypassCache action call doesn't work because the initial load was from setContent, and not from an URL. Whatever the reason, it doesn't work. We need an invalidatePageCache() function call.</p>

--- Comments ---

...and even deleting the QWebPage object and creating a new one doesn't clear the cache, for God knows what reason. The only workaround I came up with was to add "?rnd=&lt;randomNumber&gt;" to the end of local urls (with the QWebElement API) so that the cache is bypassed.

It would be even better if I could tell the QWebPage which links not to cache from now on, and for which links I want the cache to be invalidated right now.
Comment 1 Robert Hogan 2010-03-09 13:23:14 PST
(In reply to comment #0)
> This bug report originated from issue QTBUG-8438
> http://bugreports.qt.nokia.com/browse/QTBUG-8438
> 
> --- Description ---
> 
> Since Qt 4.6, there has been a QWebPage:: ReloadAndBypassCache page action. But
> it doesn't work when the page content has been set directly with
> QFrame::setContent, and the HTML used references (for instance) CSS files on
> disk. Even if those CSS files are changed after the page is loaded, triggering
> both Reload and ReloadAndBypassCache does not change the styles applied (the
> cache is used and the page doesn't see the changes).

The difference bettween the two actions is:

        case Reload:
            mainFrame()->d->frame->loader()->reload(/*endtoendreload*/false);
            break;
        case ReloadAndBypassCache:
            mainFrame()->d->frame->loader()->reload(/*endtoendreload*/true);
            break;

so in:

void FrameLoader::reload(bool endToEndReload)
{
    if (!m_documentLoader)
        return;

    // If a window is created by javascript, its main frame can have an empty but non-nil URL.
    // Reloading in this case will lose the current contents (see 4151001).
    if (m_documentLoader->request().url().isEmpty())
        return;

    ResourceRequest initialRequest = m_documentLoader->request();

    // Replace error-page URL with the URL we were trying to reach.
    KURL unreachableURL = m_documentLoader->unreachableURL();
    if (!unreachableURL.isEmpty())
        initialRequest.setURL(unreachableURL);
    
    // Create a new document loader for the reload, this will become m_documentLoader eventually,
    // but first it has to be the "policy" document loader, and then the "provisional" document loader.
    RefPtr<DocumentLoader> loader = m_client->createDocumentLoader(initialRequest, SubstituteData());

maybe we should have:

    // Create a new document loader for the reload, this will become m_documentLoader eventually,
    // but first it has to be the "policy" document loader, and then the "provisional" document loader.
    RefPtr<DocumentLoader> loader = m_client->createDocumentLoader(initialRequest, 
                      endToEndReload ? m_documentLoader->substituteData() : SubstituteData());

I think this might work as long as you specify a URL along with the setContent(). Unless it also made sense to say:

    if (m_documentLoader->request().url().isEmpty() && !m_documentLoader->substituteData().isEmpty())
        return;
Comment 2 Robert Hogan 2010-03-09 13:26:38 PST
(In reply to comment #1)
Maybe that should just be:

>     RefPtr<DocumentLoader> loader =
> m_client->createDocumentLoader(initialRequest, 
>                                m_documentLoader->substituteData());
>
Comment 3 Jocelyn Turcotte 2014-02-03 03:16:14 PST
=== Bulk closing of Qt bugs ===

If you believe that this bug report is still relevant for a non-Qt port of webkit.org, please re-open it and remove [Qt] from the summary.

If you believe that this is still an important QtWebKit bug, please fill a new report at https://bugreports.qt-project.org and add a link to this issue. See http://qt-project.org/wiki/ReportingBugsInQt for additional guidelines.