Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-16-2004, 01:15 AM   PM User | #1
circusbred
Regular Coder

 
Join Date: Apr 2004
Location: Birmingham, MI
Posts: 131
Thanks: 0
Thanked 0 Times in 0 Posts
circusbred is on a distinguished road
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?
circusbred is offline   Reply With Quote
Old 10-16-2004, 01:20 AM   PM User | #2
gsnedders
Senior Coder

 
gsnedders's Avatar
 
Join Date: Jan 2004
Posts: 2,340
Thanks: 1
Thanked 7 Times in 7 Posts
gsnedders will become famous soon enough
Strange, never had any problems myself... Try removing the no-cache code for Safari, yet keep it there for all other browsers.
__________________
Geoffrey Sneddon
gsnedders is offline   Reply With Quote
Old 10-16-2004, 01:54 AM   PM User | #3
circusbred
Regular Coder

 
Join Date: Apr 2004
Location: Birmingham, MI
Posts: 131
Thanks: 0
Thanked 0 Times in 0 Posts
circusbred is on a distinguished road
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 01:56 AM.. Reason: Heh, forgot my message
circusbred is offline   Reply With Quote
Old 10-16-2004, 01:54 AM   PM User | #4
hemebond
Senior Coder

 
Join Date: Jul 2004
Location: New Zealand
Posts: 1,315
Thanks: 0
Thanked 2 Times in 2 Posts
hemebond is an unknown quantity at this point
Why don't you want the file cached?
hemebond is offline   Reply With Quote
Old 10-16-2004, 01:58 AM   PM User | #5
circusbred
Regular Coder

 
Join Date: Apr 2004
Location: Birmingham, MI
Posts: 131
Thanks: 0
Thanked 0 Times in 0 Posts
circusbred is on a distinguished road
Because it changes depending upon certain variables... which is what makes the style sheet dynamic, which is why it cannot be cached.
circusbred is offline   Reply With Quote
Old 10-16-2004, 02:18 AM   PM User | #6
gsnedders
Senior Coder

 
gsnedders's Avatar
 
Join Date: Jan 2004
Posts: 2,340
Thanks: 1
Thanked 7 Times in 7 Posts
gsnedders will become famous soon enough
Everytime I click the link it changes... You using 1.0?
__________________
Geoffrey Sneddon
gsnedders is offline   Reply With Quote
Old 10-16-2004, 02:47 AM   PM User | #7
circusbred
Regular Coder

 
Join Date: Apr 2004
Location: Birmingham, MI
Posts: 131
Thanks: 0
Thanked 0 Times in 0 Posts
circusbred is on a distinguished road
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..
circusbred is offline   Reply With Quote
Old 10-16-2004, 03:50 AM   PM User | #8
hemebond
Senior Coder

 
Join Date: Jul 2004
Location: New Zealand
Posts: 1,315
Thanks: 0
Thanked 2 Times in 2 Posts
hemebond is an unknown quantity at this point
Why don't you just put the CSS into a style block inside the document head?
hemebond is offline   Reply With Quote
Old 10-16-2004, 12:57 PM   PM User | #9
gsnedders
Senior Coder

 
gsnedders's Avatar
 
Join Date: Jan 2004
Posts: 2,340
Thanks: 1
Thanked 7 Times in 7 Posts
gsnedders will become famous soon enough
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.
__________________
Geoffrey Sneddon
gsnedders is offline   Reply With Quote
Old 10-17-2004, 11:01 PM   PM User | #10
hemebond
Senior Coder

 
Join Date: Jul 2004
Location: New Zealand
Posts: 1,315
Thanks: 0
Thanked 2 Times in 2 Posts
hemebond is an unknown quantity at this point
How is making the browser send another seperate HTTP request for the file going to save you bandwidth?
hemebond is offline   Reply With Quote
Old 10-18-2004, 08:04 PM   PM User | #11
gsnedders
Senior Coder

 
gsnedders's Avatar
 
Join Date: Jan 2004
Posts: 2,340
Thanks: 1
Thanked 7 Times in 7 Posts
gsnedders will become famous soon enough
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.
__________________
Geoffrey Sneddon
gsnedders is offline   Reply With Quote
Old 10-21-2004, 01:21 AM   PM User | #12
brothercake
Senior Coder


 
Join Date: Jun 2002
Location: near Oswestry
Posts: 4,508
Thanks: 0
Thanked 0 Times in 0 Posts
brothercake is an unknown quantity at this point
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
brothercake is offline   Reply With Quote
Old 10-21-2004, 05:13 AM   PM User | #13
hemebond
Senior Coder

 
Join Date: Jul 2004
Location: New Zealand
Posts: 1,315
Thanks: 0
Thanked 2 Times in 2 Posts
hemebond is an unknown quantity at this point
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.
hemebond is offline   Reply With Quote
Old 10-21-2004, 06:09 AM   PM User | #14
brothercake
Senior Coder


 
Join Date: Jun 2002
Location: near Oswestry
Posts: 4,508
Thanks: 0
Thanked 0 Times in 0 Posts
brothercake is an unknown quantity at this point
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
brothercake is offline   Reply With Quote
Old 10-21-2004, 06:55 AM   PM User | #15
hemebond
Senior Coder

 
Join Date: Jul 2004
Location: New Zealand
Posts: 1,315
Thanks: 0
Thanked 2 Times in 2 Posts
hemebond is an unknown quantity at this point
What about:
Code:
<style type="text/css" media="screen,projector"></style>
hemebond is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:22 AM.


Advertisement
Log in to turn off these ads.