Enjoy an ad free experience by logging in. Not a member yet?
Register .
10-16-2004, 01:15 AM
PM User |
#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?
10-16-2004, 01:20 AM
PM User |
#2
Senior Coder
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.
10-16-2004, 01:54 AM
PM User |
#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 ( 1 => "#cce" , "#cee" , "#ccc" , "#eee" , "#ece" , "#eec" , "#ecc" );
$x = rand ( 1 , 7 );
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 01:56 AM ..
Reason: Heh, forgot my message
10-16-2004, 01:54 AM
PM User |
#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?
10-16-2004, 01:58 AM
PM User |
#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.
10-16-2004, 02:18 AM
PM User |
#6
Senior Coder
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?
10-16-2004, 02:47 AM
PM User |
#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 03:38 AM ..
10-16-2004, 03:50 AM
PM User |
#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?
10-16-2004, 12:57 PM
PM User |
#9
Senior Coder
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-17-2004, 11:01 PM
PM User |
#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?
10-18-2004, 08:04 PM
PM User |
#11
Senior Coder
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.
10-21-2004, 01:21 AM
PM User |
#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
10-21-2004, 05:13 AM
PM User |
#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.
10-21-2004, 06:09 AM
PM User |
#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
10-21-2004, 06:55 AM
PM User |
#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>
Jump To Top of Thread
Thread Tools
Rate This Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT +1. The time now is 08:22 AM .
Advertisement
Log in to turn off these ads.