« Previous Next »

Thread: All URLs return homepage html. Output Cache issue

Last post 04-14-2009 6:59 PM by ruslany. 6 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (7 items)

Sort Posts:

  • 04-01-2009, 7:31 PM

    • nootron
    • Not Ranked
    • Joined on 04-01-2009, 11:28 PM
    • Posts 4

    All URLs return homepage html. Output Cache issue

    I posted this in the IIS newsgroup.  Apologies if this is considered xposting.

    The issue is that any request to my websites returns the homepage.    For example.    A equest to http://www.mysite.com/category/post-title/ will return the homepage of www.mysite.com instead of the intended post page.   This is *not* a redirect or urlrewrite issue.   Its related to OutputCaching.   The server is returning back deep URLS with the homepage html.

    Behavior:   Seems to happen randomly, to different wordpress sites. It will also fix itself after a few minutes, but the problem will resurface anywhere from once to several times an hour.

    The experience for the user is that they click on any link or request any link to my site and they get the homepage html, despite the URL in the address window clearly changing.

    Setup:
    User-mode caching, set to 2:00 minutes.   Vary by querystring set to "*" (I optionally tried setting this to ".*" but problem still occurs).

    Win2k8 / IIS7
    PhP 5.2.9
    Latest fast-cgi windows binary (thread unsafe version)
    Wordpress 2.7.1

    Ive tried everything I can think of to isolate or further troubleshoot this issue to no avail.   Ive redownloaded the php binaries, tried various setting changes in application host file, php.ini, tweaking maxRequests and other settings, and the problem persists.

    Has anyone seen this behavior before?   What am i missing here?

     UPDATE:   I think i have figured out what may be causing it, but still can't fix it:

     Wordpress uses URL Rewriting, so perhaps the querystring is being stripped off the url before being cached by IIS?  This would result in wordpress-site.com/index.php being served up as the "cached" version of every page, no?

     A bit more searching turned up this reg fix:

     reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp\Rewrite /v RewriteCacheEnabled /t REG_DWORD /d 0

    Don't know really what it does but i have only seen the problem surface once since last night when i applied this.  

  • 04-07-2009, 12:13 PM In reply to

    • nootron
    • Not Ranked
    • Joined on 04-01-2009, 11:28 PM
    • Posts 4

    Re: All URLs return homepage html. Output Cache issue

     I cannot believe im the only one on the planet with this issue.    I moved from apache/eaccelerator because of the praise IIS7 has gotten from this site.

    The bug seems so HUGE and apparent that im amazed there is nothing on usenet or the general web that implies others have this issue.

    Im using a standard cookie-cutter setup.   Php, wordpress, IIS7, and output caching.   And randomly, different sites at different times start serving up site.com/index.php for EVERY page that is requested.   Restarting IIS fixed the issue 50% of the time.   Sometimes the problem resurfaces immediately.

    Im begging the IIS community here.   Please help.   Im not doing anything out of the ordinary with my setup whatsoever.    Yet this bug is completely game-breaking and unacceptable.   

  • 04-07-2009, 11:05 PM In reply to

    Re: All URLs return homepage html. Output Cache issue

    What URL rewriting tool are you using? By saying that it isn't a rewrite issue I take it that everything starts working as soon as you disable IIS 7 output cache? I haven't used the IIS 7 output cache with Wordpress, however I have used it with other PHP apps that use SEF URL's without too much issue. Unfortunately by using user-mode cache there is no way of seeing exactly what is in the cache (to my knowledge at least).

    Have you read this thread?

    http://forums.iis.net/t/1150527.aspx

    Some good content for output caching.

    ----------------
    Dominic Ryan
    Microsoft IIS MVP
    www.iis-aid.com
    My IIS articles
    My PHP articles
    My How-to guides
  • 04-08-2009, 1:39 PM In reply to

    • ruslany
    • Top 25 Contributor
    • Joined on 07-01-2007, 7:38 PM
    • Redmond, WA
    • Posts 661

    Re: All URLs return homepage html. Output Cache issue

    Can you please try this:

    1. Remove the vary by querystring

    2. Add varyByHeaders="x-original-url"

    I've tries this caching configuration with WordPress and URL rewrite and it works for me: 

    <add extension=".php" policy="CacheForTimePeriod" kernelCachePolicy="DisableCache" duration="00:00:30" varyByHeaders="x-original-url" />

    http://ruslany.net
  • 04-08-2009, 2:51 PM In reply to

    • nootron
    • Not Ranked
    • Joined on 04-01-2009, 11:28 PM
    • Posts 4

    Re: All URLs return homepage html. Output Cache issue

    Thank you brashquido and ruslany for your responses.   It is much appreciated :)

    To answer brashquido:   Im using the provided IIS7 rewrite module for url rewriting.  I had seen that article as well.   I dare say there's not a usenet thread or web page on the entire interweb I have not perused at least once.  :P

    Ruslany:  I went ahead and gave this a try.  Am i correct in assuming I should keep kernal mode caching disabled?   Given that this problem is intermittent, I will test it out for a few days and post here with the results.

    ---

    Just to reiterate:   output caching does work...sporatically.   But at random times for unknown reasons, some or all of my sites start returning the wordpress homepage for any and every url requested.   Headers show I am correctly requesting a deep url, but IIS says "I know you wanted that deep link, but here's the homepage instead!  enjoy."

    It seems like an IIS rewrite + output caching issue because (1) It never happens with output caching turned off (2) The homepage is always what is cached when the problem happens, not some random deep page.  (3)  wordpress installations are basically all website.com/index.php?various-querystrings, essentially all pages are the homepage.

    So the conclusion i came to with next to no evidence (:P) is that for some reason, the output caching engine is being given the URL with the QueryString stripped off.  It then caches site.com/index.php and that gets served up for anyone requesting any page.

    Many thanks again guys for the replies.   Im eager to see how this x-original-url works.   ruslany, is this some internal header that IIS uses?  I dont see it anywhere in Live Headers...

    Cheers,

    Will
  • 04-14-2009, 6:14 PM In reply to

    • nootron
    • Not Ranked
    • Joined on 04-01-2009, 11:28 PM
    • Posts 4

    Re: All URLs return homepage html. Output Cache issue

    Follow-up, part duex:

    Ruslany's solution did solve the issue of the homepage being served up for deep links, but unfortunately it brought with it a few other bugs:

    -  Im having editors report that while using the back end of wordpress (/wp-admin/ area), they are seeing caching happening there.    ONe example is an editor clicks "publish" and they then see a different post than the one they just published.   Another common one is that they cannot log in or out until the cache expires (every 1:30 seconds).

    To deal with the above, i decided to use VaryByQuerystring "*" AND also keep the vary by header recommendation that Ruslany gave me.

    This fixed the above issue, but presented a much more severe issue:   Commenters complained that they were seeing other commenters' information in the comment box when loading one of our post pages (including the other commenters' email address).   This is obviously not sitting well with management, so im back to the vary by header solution only.

    Is there a way to vary caching so that anything in wp-admin doesnt get cached but the rest of the Wordpress installation does get cached?    And has any one had an issue where commenters' info is getting cached along with pages?  

    Cheers all
  • 04-14-2009, 6:59 PM In reply to

    • ruslany
    • Top 25 Contributor
    • Joined on 07-01-2007, 7:38 PM
    • Redmond, WA
    • Posts 661

    Re: All URLs return homepage html. Output Cache issue

    You can disable all caching for wp-admin folder by adding this to the web.config located in the wordpress root folder:

    <location path="wp-admin">
        <system.webServer>
            <caching>
                <profiles>
                    <remove extension=".php" />
                    <add extension=".php" policy="DisableCache" kernelCachePolicy="DisableCache"  />
                </profiles>
            </caching>
        </system.webServer>
    </location>

    Note that this should be added right under the <configuration> element in web.config file.

    http://ruslany.net
Page 1 of 1 (7 items)
Microsoft Communities