I'm developing a custom plugin which connects to salesforce and needs to check that the connection hasn't expired on each page refresh. If it does expire, it reconnects etc.
So I am doing this on an init action, but I've noticed a very significant performance hit doing it this way. Particularly loading images from the media library. My understanding now is that init fires with every request, so on a page with 20 images, it will fire at least 20 times??? Is this correct?
So obviously init isn't the best for this purpose, what should I be using?
admin-ajax.php(which wp admin checks regularly for auth verification). Such remote requests should make the site slow and it would be better to process them via AJAX.