ionic-team / cordova-plugin-ionic-webview

Web View plugin for Cordova, specialized for Ionic apps.
Apache License 2.0
484 stars 391 forks source link

How does this webview manage CORS preflight caching ? #656

Open rolinger opened 2 years ago

rolinger commented 2 years ago

What are the defaults for handling CORS preflight caching? It appears on Android device its set to 10minutes...I haven't checked iOS yet. From the client/app perspective, can they be overridden?

On normal browsers like chrome or safari the CORS preflight can be cached - but those browses cache them at different intervals. I believe chrome is hard set to 10 minutes, Firefox is two hours but Safari is like 24 hours (I could be wrong on the ordering). But what are the ionic-webviews bound to?

I ask because in my ionic app, switching between views causes CORS preflights to execute again. It appears any first call to a server script is calling a new CORS preflight. If page view auto calls getInfo.php - then a CORS preflight is cached just for that script, if any call to that script happens again, the cached preflight is used. But If on the same page view, a user clicks a button that makes a call to the server script showInfo.php then a new CORS preflight is created. Is it possible to have all server api calls use the first cached CORS preflight info?

How would $http headers cache impact the use of CORS caching?....can any of those $http caching headers override or impact the CORS caching sent from the server with the Header always set Access-Control-Max-Age: 86400 set?

I created an SO question regarding this, providing more technical detail, but so far it hasn't gotten any responses that really answers the questions. https://stackoverflow.com/questions/69812308/cordova-page-view-cache-vs-http-cache-vs-cors-preflight-caching