So I'm developing an iOS app based on WKWebView. It's generated by Cordova. My problem is that every time I load the images from the server it may be slow coz the connection to the server is sometimes really slow. I tried to save the images to cache but it still can be slow sometimes coz I found in the console that my WKWebView is still gonna talk to the server (304) to verify the version of my cached images. Is there any method that I can use to block that 304 request and load cached images directly?
I believe WKWebView should automatically (or rather by default) take advantage of the caching hints in your HTTP header. You need to set-up/increase leverage browser caching on your sever. How you do this depends on what server you're using, but it is generally easy to do. Using the Apache web server you need to edit your server config (usually at /etc/httpd/conf/httpd.conf) to Include conf/extra/httpd-leverage-cacheing.conf
and edit that sub-config file as needed. Typically, images are considered good to use for 1 to 4 weeks, depending on how often they change.