Managing cache

Next, let's talk about a cache. There are two types of cache which you can use in the web engine module, namely, Memory Cache and Disk Cache. Memory Cache uses the computer's memory to store the cache, which will be gone once you've closed the program. On the other hand, Disk Cache saves all the files in the hard disk, and hence they will still remain, even after you've turned off your computer.

By default, the web engine module saves all the cache to the disk, if you need to change them to Memory Cache, call the following function:

QWebEngineProfile::defaultProfile()->setHttpCacheType(QWebEngineProfile::MemoryHttpCache); 

Alternatively, you can also disable caching completely by calling:

QWebEngineProfile::defaultProfile()->setHttpCacheType(QWebEngineProfile::NoCache); ...

Get Hands-On GUI Programming with C++ and Qt5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.