We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27376
    • 576 Posts
    This may be an issue with my server and not MODx, but I want to get some other opinions before I rip my hair out re-building my server.

    I have a seemingly un-predictable bug that I cannot duplicate, but it happens frequently:

    My links on the my MODx site every once in a while will not write the site_url at the beginning of it so I end up with links like this at in my site: [tt]http:///staff/[/tt]. I’m using the [tt]<base href="[(site_url)]"/>[/tt] method in my templates. Since [( .. )] settings are cached with pages I waited until the issue came up, then checked the site cache and my template looked like this: [tt]<base href="http://" />[/tt]

    I can only come to the conclusion that, since [tt]$site_url[/tt] is automatically generated from $_SERVER vars (like HTTP_HOST), when a request comes in, the $_SERVER array is not completely populated. However, every scenario I’ve tried passes, and this issue only came up when I made the site live (all my production tests didn’t have this issue).

    I disabled SEO Strict Urls and the issue still comes up.

    Anyone else have an idea? Need more information?

    Apache 1.3.33
    PHP 4.4.1
    Mac OS X 10.4.8

    This is somewhat of an emergency, though I’ve temporarily fixed the issue by hardcoding the <base href=""/> url, but now I can’t switch between production and live site as easily :-/
      • 27376
      • 576 Posts
      UPDATE

      I figured it out, and the scenario is rather unique so I won’t go in to details. The problem occurs when our InterMapper server is the first request to the home page (in other words, before the home page is cached). I can’t explain it precisely since I don’t know the inner workings of InterMapper nor Apache, but it seems to be sending an incomplete request to MODx and the $_SERVER array has an empty ’HTTP_HOST’ variable.

      Perhaps a feature we could implement with MODx is checking of the $site_url variable that it is not equal to "http://" or something similar.

      UPDATE: I made a little workaround plugin to automatically cache the home page when the cache is cleared.
      /**
       * Query Home Page
       *
       * Automatically Cache the home page whenever the cache is cleared
       * 
       * Events Selected: OnCacheUpdate
       */
      $file = file($modx->config['site_url']);
      

      That simple! I think it would be a great idea to have an option in the Configuration to automatically cache the home page. Though my issue is very specific, there might be other reasons people would want to cache the homepage immediately...