MODx context problem US context pages go to 404 every so often

We have a site with two contexts: Web and US. We are using Babel and LangRouter to manage routing and switching between context pages. Everytime we switch to the US context and navigate around different webpages, or refresh the current one, after 1 or 2 pages it will result in us getting a 404 error for the requested US context page and switches back to the web context.

Once we get the 404 error, after one or two refreshes we then switch back to the US context. However this problem does continue with the contexts repeatedly switching back and forth because of the 404 error.

Has anyone else encountered any similar problems before?
Thanks

Environment:
Modx Revolution 3.0.1-pl
Babel 3.1.1-pl
LangRouter 1.4.1-pl

I also experienced this, after I searched for information on forums, I finally found a solution.

for my case. The first thing I missed was to give anonymous user group permissions for each context with Access Policy Load only and set session_cokie_domain in the system setting.

Thanks for the response!

We’re still encountering the same problem after changing the Access Policy for the 2 contexts from Load, List and View to Load Only, and set the session_cookie_domain to the site domain.

did you put a dot in front of your domain, like .mydomain.com?

this is my settings

anonymous_sessions = yes
session_cookie_domain = .mydomain.com
session_cookie_path = /

Yep. The primary context is subdomain.domain.co.uk whilst the other context is subdomain.domain.co.uk/us/

The session_cookie_domain was set to .subdomain.domain.co.uk, also tried it with .domain.co.uk but both don’t seem to solve the problem.

After investigating this issue further it turns out it is caused by the context_settings cache folder being turned off in system settings. However, when turning the cache for this folder on, the context_settings folder causes the context to stop working completely when you save a resource (templates, snippets etc).

Are there any known problems with the context_settings cache folder and anyone who might’ve experienced any similar problems?

It does sound a lot like this will be ACL-related. Can you provide a screenshot of both your contexts’ permissions setup? Right click the context to edit it, and then take a screenshot of the permissions tab so everything is nicely in one place.

Here’re the Access Permission setups for our contexts.

I’d use “List, load & view” for the anonymous usergroup, but that seems pretty standard.

Make sure to flush all permissions (manage menu > logout all users) after making changes.

If it breaks again, can you check the file(s) in core/cache/langrouter/ to see if that has all the relevant info?

Unfortunately it did break again after following your instructions, the cache/langrouter has 1 file “langrouter.contextmap.cache.php” file inside. Thanks.

… and what’s in that file? I’m not psychic :wink:

Is that file different between when it does and does not work?

My apologies, it was a long day yesterday!

The contents of the file are the same both before and after the context breaks:

<?php return array ( 'en' => 'web', 'us' => 'usa', );

Looks like there’s a similar post here relating to multi-lingual & context settings cache, although involving XRouting rather than LangRouter.

Sadly, even though it’s marked as ‘solved’, as far as I can see, the OP abandoned using contexts in the end and set up a separate virtual server for the second language.