Caching means WordPress will serve static cached content.
Usually cache plugins have an option to enable different caches for mobile/tablets. You can enable the option then the device detection will work.
If the cache plugin doesn’t have such an option, it means it will serve the same static cached content regardless of the current device and web browser, then the detection will not work.
Currently the detection is done on the server side.
When a page is cached, the cache plugin will directly display the static cached content, without going through the detect plugin.
A solution for this issue is to add an option to detect the devices and web browsers on the client (web browser) side. We will support this option in a future version.