Hi,
I’m using mobile theme, but there’s some problem when I use page caching. (I use Fastcgi_cache with Nginx)
If I enable the cache, the mobile theme will not show up. It shows original mobile layout instead.
But if I cached mobile theme first, the desktop version is gone, vice versa.
Is there any solution? Thank you!
Hi,
The mobile theme is sensitive when it comes to caching. It is compatible with the WP Super Cache which is the only caching plugin we have tested up to this moment
– https://forum.tagdiv.com/the-mobile-theme/
You could consider using that caching plugin, or deactivate the mobile plugin which is not working properly in those circumstances.
Thank you!
Hi Simon,
I have figured out the solution, provide as below:
When you set a FastCGI cache, make sure add a variable to specify agent, for now I’ll use $mobile_request
And we can add the code to http block:
set $mobile_request 0;
if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino") {
set $mobile_request '1';
}
if ($mobile_request = '1') {
set $skip_cache 1;
}
next, find your fastcgi_cache_key section,
then add $mobile_request to the end of code.
For example:
fastcgi_cache_key "$scheme$request_method$host$request_uri$mobile_request";
This should be working, just remember to reload the NIGNX server.
Hope this helps.
-
This reply was modified 8 years by
Atelier Shen.
Hi Ginfox,
I have found a solution on WordPress.org forum, post by staff of SG. You can try this out:
function add_vary_header($headers) {
$headers['Vary'] = 'User-Agent';
return $headers;
}
add_filter('wp_headers', 'add_vary_header');
Add code above to your function.php file in Newspaper-Child theme folder. This will make different cache for each device.
Sorry I didn’t use SiteGround for a long time, so I’m not able to test for you. But I guess you may reply to https://wordpress.org/support/topic/configure-mobile-theme-for-supercacher-siteground/ if you need further support.
Happy Coding!
Atelier Shen
-
This reply was modified 8 years by
Atelier Shen.
