Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Regular Coder
    Join Date
    Apr 2004
    Location
    Birmingham, MI
    Posts
    131
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Safari, Cache, You & Me

    I have a dynamically driven external CSS file, which is strictly told not to cache itself, yet Safari thinks it is a good idea to indeed cache that file. Yes, this is the example from php.net
    PHP Code:
    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"); 
    The css file still caches in Safari when linked! However, if I head on over the the dynamic css file directly, it doesn't cache.

    Is my only real solution here inline styles or can Safari be beaten into submission?

  • #2
    Senior Coder gsnedders's Avatar
    Join Date
    Jan 2004
    Posts
    2,340
    Thanks
    1
    Thanked 7 Times in 7 Posts
    Strange, never had any problems myself... Try removing the no-cache code for Safari, yet keep it there for all other browsers.

  • #3
    Regular Coder
    Join Date
    Apr 2004
    Location
    Birmingham, MI
    Posts
    131
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Safari is evil!!

    Quick Example:
    http://beta.circusbred.com/wtf.htm

    wtf.php source:
    PHP Code:
    <?php
    header
    ("Content-Type: text/css");
    // Date in the past
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

    // always modified
    header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT");
     
    // HTTP/1.1
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0"false);

    // HTTP/1.0
    header("Pragma: no-cache"); 

    $color = array (=> "#cce""#cee""#ccc""#eee""#ece""#eec""#ecc");
    $x rand(17);
    echo 
    '
    #box {
        background-color:'
    .$color[$x].';
        top:50px;
        height:250px;
        border: 1px dashed #000;
        padding:50px;
        width:500px;
        position:absolute;
        left:50%;
        margin-left:-250px;
    }'
    ;
        
    ?>
    EDIT #1: As you notice, Safari will cache the CSS file & the box will stay the same color unless you hit REFRESH.

    EDIT #2: I tried removing no-cache, still the same problem.
    Last edited by circusbred; 10-16-2004 at 02:56 AM. Reason: Heh, forgot my message

  • #4
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Why don't you want the file cached?

  • #5
    Regular Coder
    Join Date
    Apr 2004
    Location
    Birmingham, MI
    Posts
    131
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Because it changes depending upon certain variables... which is what makes the style sheet dynamic, which is why it cannot be cached.

  • #6
    Senior Coder gsnedders's Avatar
    Join Date
    Jan 2004
    Posts
    2,340
    Thanks
    1
    Thanked 7 Times in 7 Posts
    Everytime I click the link it changes... You using 1.0?

  • #7
    Regular Coder
    Join Date
    Apr 2004
    Location
    Birmingham, MI
    Posts
    131
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hehe. I suppose I should have stated the version...
    1.0 (v85) for 10.2.8

    Good to know that it was fixed though.
    Last edited by circusbred; 10-16-2004 at 04:38 AM.

  • #8
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Why don't you just put the CSS into a style block inside the document head?

  • #9
    Senior Coder gsnedders's Avatar
    Join Date
    Jan 2004
    Posts
    2,340
    Thanks
    1
    Thanked 7 Times in 7 Posts
    Quote Originally Posted by circusbred
    Good to know that it was fixed though.
    Heh... about everything except some more advance XML stuff was fixed



    Quote Originally Posted by hemebond
    Why don't you just put the CSS into a style block inside the document head?
    Bandwidth.

  • #10
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    How is making the browser send another seperate HTTP request for the file going to save you bandwidth?

  • #11
    Senior Coder gsnedders's Avatar
    Join Date
    Jan 2004
    Posts
    2,340
    Thanks
    1
    Thanked 7 Times in 7 Posts
    Quote Originally Posted by hemebond
    How is making the browser send another seperate HTTP request for the file going to save you bandwidth?
    Because I'm an idiot.

  • #12
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    But there's no good way to "hide" <style> contents from legacy browsers - using an external file is the right way.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #13
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Does
    Code:
    <link rel="stylesheet" type="text/css" href="/css/index.css" media="screen,projector">
    not hide it from old browsers? Plus, if you want to hide your stylesheets from certain browsers, you should use a server-side language to blacklist them, and not serve them the style.

  • #14
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yeah it does - exactly. Putting it in a <style> block in the head does not.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #15
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    What about:
    Code:
    <style type="text/css" media="screen,projector"></style>


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •