-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems with cached 302 language redirects with W3 Total Cache browser caching #306
Comments
Thanks a lot for the report of this unusual issue. Does W3 Total Cache work in all other respects? I would assume that there are many other problems. Generally every caching plugin tries to be smart and caches some queries, which in fact run differently for pages with different languages, but they have no way to take that into account. It caused me to give up using caching for now. But things are improving every day, may be now W3 Total Cache is usable with qtx. Please, let me know if you find more issues. How complex is your site? Do you use Woocommerce or something like that? About redirect. 303 is redirect with method GET, which will mostly work, but would not it be safer to use 307 then? What does W3 Total Cache do exactly to make browser to cache redirects? |
Just to have a link handy: http://stackoverflow.com/questions/2068418/whats-the-difference-between-a-302-and-a-307-redirect |
W3 Total Cache seems to work fine - at least I didn't notice any unexpected behavior. The site is not really complex - it has a few static pages, and a number of posts in various categories, but generally most of the content is WordPress based (apart from a few additions for sliders/Google map and so on). No Woocommerce here. Well, if 307 is a safer choice, it might be used as well. I can perform the same testing using 307 instead of 303. Regarding the question about the cause - I can revert to simple |
Yes, please test 307. Thanks a lot. Maybe we should make that code to be an option? |
An option would be a great move IMO. I will get back to you after I compare those response headers with and without browser cache function in W3 Total Cache. |
Ok, so I did the testing. Whenever browser cache is enabled, response headers contain additionally (comparing to this option disabled) these fields while doing the redirect:
I have got a huge file with all of these headers, but I think that listing the differences is enough at this stage. I have also made a few interesting observations:
Currently I am using a simple |
Hi, |
WordPress uses 302 as a default choice for their wp_redirect and they use it a lot. I did a search and they never use anything, but 301 and 302, and 301 is only in the places to redirect obsolete code. How does that work for them? Having this as an advanced option is ok with me if somebody implements it and submit a pull request ;) Are you both sure that there is no a simpler solution? Maybe W3 Total cache has some options to deal with it? Probably not though ... Let us hope that somebody will take an initiative to implement an option. |
Hi, For us the fix with 303 redirect was mostly working. However, on rare occasions visitors ended up being redirected from the correct url to a non-existing one, resulting in 404. I agree that if WordPress uses 302 as a default choice, then the problem might be somewhere else. I did some more digging into this, and it turned out that the mechanism responsible for language detection might be involved. I've gathered some print_r outputs from the plugin work and my observations lead to the conclusion that if there is a conflict between the cookie and url language, the website might throw 404. Consider the following: Dump from qtranxf_init_language: detected: url_info:
Resulting debug message:
The worst thing with trying to figure out this behaviour is that really all works just fine in most of the cases :) You can switch languages either through a button, or simply by adding At times however, even though in the original URL there is no Temporarily we are using an ugly hack, that sets the |
QTX does not manipulate slugs. In QTX, redirection I never realised that you use QTranslate-Slug and you should definitely discuss this issue with them and not here. @lemartinet: do you also use QTranslate-Slug? |
@johnclause you are right, sorry for that. I really thought I included my full set-up in the first message. |
Let the authors know about this topic: https://github.com/not-only-code/qtranslate-slug |
Hi
|
Hello guys, is that possible to include a directive in the header to disable all caching for the current request? I guess, this would solve all the problems in a simplest and safest way? What would be the syntax of such directive? |
Seems like this works:
Could you all try it, please? |
Edit: I switched two lines around in the previous message so that "header" goes after "wp_redirect". I was testing on the server where caching is induced by .htaccess file and then the order does not matter. But in case of caching plugin, it may employ filters inside Alternatively, it maybe even better to do:
to disable filters inside wp_redirect. Please, let me know how and if it works for you. |
Thanks for the idea, I'll try to play with it this WE and let you know the Manu On Thu, May 5, 2016 at 11:48 PM, johnclause [email protected]
|
I updated https://github.com/qTranslate-Team/qtranslate-x/archive/stable.zip with a change. WP even have a function I am closing this issue, assuming it works now, please test, we can still write into closed issue and we can re-open it if needed. Thank you all for your help. |
Hi,
I'm assuming it's somehow related to the same caching issue. Do you have an idea how to test and fix that? Thanks! |
I could not reproduce the problem. I tried in a few browsers and on my phone. Maybe they are your old customers who still have that permanent redirection in their browsers? I am not sure how long it takes to expire? |
Thanks for your answer. I'll keep you posted if I have more info about this On Thu, Jun 16, 2016 at 3:12 PM, johnclause [email protected]
|
I have faced a bug that prevents qTranslate-X from switching languages properly. I'm using WordPress 4.3.1 and qTranslate-X 3.4.6.4. My setup has two languages: pl (default) and en.
Steps to reproduce:
At this stage it is impossible to switch back to the default PL language, as all requests looking for GET / are from now on treated according to browser cache, so GET / = [cached 302] = GET /en.
Even without the option to hide the default language, visiting http://website.domain/ still uses browser's cache, so I'm ending up in a redirection leading me towards /en until I clear the cache.
Such behavior is not observed if I disable web browser cache option in W3 Total Cache plugin.
The solution:
inside
qtranxf_init_language
function (line 80), there is a call towp_redirect()
.Changing it from:
to:
solves the issue for me, as 303 redirects according to the standard are not to be cached in the browser.
Any chance for changing this redirect in the next qTranslate-X release?
The text was updated successfully, but these errors were encountered: