We just setup Cloudfront on our Wordpress site. The site also has W3 Total Cache running. The site has a lot of code that uses the server side WP_Is_Mobile() function to show or hide certain content based upon if the person is on a mobile device or desktop.
On W3 we setup the User Agent Groups to create a separate cache for the mobile. That worked great. However, when we moved to Cloudfront this no longer worked. My guess is that Cloudfront sends only over the "Amazon Cloudfront" user agent so W3 cache has no way to tell if it's mobile or not.
We are able to get Cloudfront to work without W3 Cache by modifying WP_Is_Mobile to check for $_SERVER['HTTP_CLOUDFRONT_IS_MOBILE_VIEWER']. Cloudfront is passing that back in the header so we can check server side. If we have cloudfront pass the user agents back then that will defeat the purpose of its caching (with all the versions it would have to cache)
I'm wondering how to do I still use W3 Cache with Cloudfront so I can take advantage of the combined benefits. Can W3 cache different versions based upon the header values that Cloudfront sends over (e.g. $_SERVER['HTTP_CLOUDFRONT_IS_MOBILE_VIEWER'])
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire