Pergunta

I'm at a loss here.

I have a new Wordpress site at synergration.com.

If you access it on a mobile device (phone, not tablet) it will generally load fine the first time. Once you click on to another page and/or reload the home page it jumps into a redirect loop indefinitely attempting to reload the same page over and over and over...

I've weeded through the code and have been unable to find any JS redirects. I've also contacted the theme developer and they've been unable to help.

This only became an issue when I started hosting on WP Engine. They use some advanced caching that seems to be the culprit here as when I test the mobile site on their staging server (where no cacheing exists) it loads fine.

I contacted WPEngine about it and this was their reply:

This is being caused by our caching systems that run on our platform. It looks like the theme is handling an internal redirect that detects the user agent (desktop or mobile) and redirects the visitor to the appropriate site based on that information. However, the redirect is getting stuck in cache, causing the mobile version to load in an infinite loop. Unfortunately, we don’t have an easy solution for this. If this were only one part of the site, we could just exempt that part of the site from caching, but because it covers the whole site, exempting from caching isn’t an option. Our staging area is exempt from all caching, which is why it’s working normally there. (The old host was most-likely using a non-cached environment, which is why you didn’t see this issue there). I would contact the theme developer and ask them if they’ve ever come across this issue before. There’s a good chance they have, and they might have a clever solution as a work-around. You might have the option of disabling the mobile routing, which would solve the redirect issue, though mobile devices would load the full version of the site rather than the slimmed-down mobile version.

As noted above, the theme developer didn't have any solution and I'm back at square one so I figured I'd reach out to stack to see if ya'll had any ideas.

Foi útil?

Solução

I have two sites on WP Engine with redirect. They are identical gensis child themes and redirect plugins. I have one setup with a DNS redirect to a cname record for a "M.sitename.com" URL and the other redirecting to the mobile site that is having the same issue you noted above. I haven't had an issue with the site that points to the cname record. I am about the change the other site to the cname configuration to see if it makes a difference. I have no ideal why this works, but thought you might find this of value.

Outras dicas

It works absolutely fine in my mobile's Opera Mini browser. To answer your question, an alternative way is to just create a mobile subdomain, like m.yourdomain.com. Make this decision public and let mobile users know in advance that that is the site for mobile users. A specific mobile site is loads better than visiting the page and then being redirected. It also saves time.

While developing the mobile site, keep in mind, to use minimal JavaScript. The reason being, that older mobile versions may not support JavaScript and if JavaScript is essential then it becomes a big problem.

Speaking about the theme, if it is getting stuck and developer has no idea, so the best option, FOR NOW, is change the template. Let the developer inspect on his very code. You can by that time use another template, that'll keep the site up running well whether it is on Mobile or anything. Because, small errors can divert lot of traffic from your site. I, to be frank, have no idea about what caching problems WP is having, and I don't expect anyone here to be knowing that, so it really depends on time. Till then, as I said, do try to use some other template for the time-being.

All the best.

I faced similar issue recently. It took good amount of time but I finally figured it out.

To prevent redirect from caching, you have to use 302 redirect. Moreover, you have initialize this redirect in "template_redirect" action of wordpress. If you do it in like "init", it'll be cache too.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top