Problems with iWeb and Browser Caching (I think)

Discussion in 'Web Design and Development' started by EricNau, Jul 31, 2007.

  1. EricNau Moderator emeritus

    EricNau

    Joined:
    Apr 27, 2005
    Location:
    San Francisco, CA
    #1
    I have a website, made in iWeb hosted through ASO.

    In iWeb I have two sites, "Mission" and "Church" (Mission is the default site). I also have a third site that I created, "update," which was created on a separate machine, and resides on the server constantly, but is only used while I'm updating the site.

    So, in my www folder, there are three folders: Mission, Church, and update, plus one index file. That index file usually directs to Mission, and from there users can access Church. ...update is used when I'm updating the site, and I replace the index file so users are directed to my "we are currently updating" page.

    Does all this make sense so far?

    ...My problem is this: It seems, that if a user accesses the site while we're updating, and are directed to the "we're updating" page, when they return, the browser still directs them to my update page, even after I'm done and switched the index files back to normal. ...If I remove the update folder altogether, they get a 404 error.

    This problem seems worst in FireFox (it absolutely refuses to direct to the proper site), and in Safari, pressing reload will usually fix the problem (still not ideal).

    Any comments or suggestions are greatly appreciated.
     
  2. janey macrumors 603

    janey

    Joined:
    Dec 20, 2002
    Location:
    sunny los angeles
  3. EricNau thread starter Moderator emeritus

    EricNau

    Joined:
    Apr 27, 2005
    Location:
    San Francisco, CA
    #3
    Thanks for the links, but for the most part, they go over my head (and abilities, considering I'm using iWeb). Plus, everything they're suggesting would just be over-kill for my simple site.

    Basically, I think the major problem is that the browsers aren't re-reading the index file, which has changed. Here's how simple it is:
    Code:
    <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title></title><meta http-equiv="refresh" content="0;url= Missionary/Mission.html" /></head><body></body></html>
    The only thing that ever changes is the file name, which sometimes reads Missionary/Mission.html or Church/Home.html or update/index.html, depending on where I want to direct everybody at that time.

    Could something as simple as that be cached, or do I have a problem unrelated to caching?
     
  4. angelneo macrumors 68000

    Joined:
    Jun 13, 2004
    Location:
    afk
    #4
    Are you using some backend script like php or asp to redirect your users? If that's the case, you can avoid caching by dynamically changing your url everytime with some useless info

    eg. attaching session id or datetime stamp to the end of your url.
    update.php?session=FSSKcu2kde0 or
    update.php?check=20070731113123

    I'm not sure how you redirect, or did you just replace the entire index file with another copy via ftp or something?
     
  5. EricNau thread starter Moderator emeritus

    EricNau

    Joined:
    Apr 27, 2005
    Location:
    San Francisco, CA
    #5
    Exactly. For example, if I want to update the site, I swap out the index file directing everyone to the Missionary page, with the index file directing everybody to my update page. Once I'm done, I just replace the original index file.

    Basically, here's what my "www" folder looks like:
     

    Attached Files:

  6. EricNau thread starter Moderator emeritus

    EricNau

    Joined:
    Apr 27, 2005
    Location:
    San Francisco, CA
    #6
    Also, once the browser directs them to the wrong folder/site, even hitting reload won't help, because it'll just reload the wrong site.

    It's like I need to place a big red flag on the index file that says "Pay attention to me every single time!!!"

    ...Does that make sense?
     
  7. angelneo macrumors 68000

    Joined:
    Jun 13, 2004
    Location:
    afk
    #7
    so that file basically has a javascript or a refresh header that automatically redirects them? and you change that file location everytime you do an update? or it's a link on that page?

    EDIT: Ignore the above, I just saw your meta-header

    EDIT 2: How about you replace that file with the following
    Code:
    <?php
    header("Location: Missionary/Mission.html");
    ?>
    
    and change the file name to index.php
     
  8. EricNau thread starter Moderator emeritus

    EricNau

    Joined:
    Apr 27, 2005
    Location:
    San Francisco, CA
    #8
    Yes. The code posted above is the entire index file. It's simply there to direct users to one of three sites I have.

    Not sure I understand. I never change file locations, per se. I just swap index files.


    EDIT: OK, ignore this post too. :D
     
  9. angelneo macrumors 68000

    Joined:
    Jun 13, 2004
    Location:
    afk
    #9
    I'm not sure how your shared hosting cached your files, so by using php, it might flag it. Give it a try, there are some more ways to avoid caching, let me know if the above does not work.
     
  10. EricNau thread starter Moderator emeritus

    EricNau

    Joined:
    Apr 27, 2005
    Location:
    San Francisco, CA
    #10
    That works wonderfully in Safari 3, but Firefox is still being ornery. No matter what I seem to do, it still directs directly to the update page (because that's the first page it was ever directed to).

    Janey's link above contained this code. Doesn't make any sense to me, but you probably know. ...Is there any way to combine your code with this:

    Code:
    <?php
     Header("Cache-Control: must-revalidate");
    
     $offset = 60 * 60 * 24 * 3;
     $ExpStr = "Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT";
     Header($ExpStr);
    ?>
     
  11. angelneo macrumors 68000

    Joined:
    Jun 13, 2004
    Location:
    afk
    #11
    That code set a date time for expiration of the cache which i believe the code set it to 3 days. You can do a "do not cache" version
    Code:
    <?php
    header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' );
    header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
    header( 'Cache-Control: no-store, no-cache, must-revalidate' );
    header( 'Cache-Control: post-check=0, pre-check=0', false );
    header( 'Pragma: no-cache' );
    
    header("Location: Missionary/Mission.html");
    ?>
    
     
  12. EricNau thread starter Moderator emeritus

    EricNau

    Joined:
    Apr 27, 2005
    Location:
    San Francisco, CA
    #12
    Oops. I just realized, I should have warned you: I sent both of you PMs with a link to the website, but I've been changing things constantly, so your viewing experience may be less than optimal. :D
     
  13. EricNau thread starter Moderator emeritus

    EricNau

    Joined:
    Apr 27, 2005
    Location:
    San Francisco, CA
    #13
    OK, very interesting...

    As it turns out, even that last code didn't work in Firefox (everything has worked fine in Safari).


    In the past, it's never mattered if I typed the "www" in the domain name or not. My bookmark in safari does not contain the www, and I wasn't typing it in Firefox either. ...As it turns out, if I do, then Firefox works prefectly (even with my original html index file).

    ...So I guess that's my problem. :confused: That doesn't make any sense to me. :confused:
     
  14. angelneo macrumors 68000

    Joined:
    Jun 13, 2004
    Location:
    afk
    #14
    Strange, normally the hosting company would link both "www" and without "www" to the same location. I tried without "www" on my firefox, and it seems to be working perfectly (perhaps, since it is the first time I visited the site), or could be some strange bug at work here. I'm glad that it is working for you now.
     
  15. EricNau thread starter Moderator emeritus

    EricNau

    Joined:
    Apr 27, 2005
    Location:
    San Francisco, CA
    #15
    Possibly.

    It's still a little concerning, considering I don't really know what's going on, but for now, I don't think there's much I can do. Maybe I'll submit this thread to ASO and see what they have to say about it.

    Anyway, thanks for all your help! It is much appreciated!
     

Share This Page