Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
How can I prevent the server side caching?
Old 08-17-2008, 09:54 AM How can I prevent the server side caching?
Novice Talker

Posts: 10
Trades: 0
Hello >>

This is my first visit and post in webmaster-talk. it's an honor and a privilege to be with you all.

As mentioned in thread subject

My site contain dynamic pages, it is a script using php&html with mysql database. Daily when i do update the pages through script's back-end, homepage will still showing the previous update until refreshing the page. and my visitors face the same problem.

I used 4 computers and 3 defferent ISP and that did not fix the issue, so it is not browser cache and not ISP cache, and there is no options in script's back-end to turn cache on or off. thats all make me sure it is server-side caching.

I'm looking for a way to prevent this because I'm constantly updating the site and it is impossible to ask my visitor "Please press refresh on each visit"

Apparently, there are "no-cache" code that can be put into meta
tags. I try this also .. but didn't work

I'd be grateful for any light that can be thrown on this server side
caching problem.
WMASTER is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-17-2008, 12:59 PM Re: How can I prevent the server side caching?
bas
Super Talker

Posts: 108
Name: Bas
Trades: 0
Server side caching? never heard of that, you say:
Quote:
it is impossible to ask my visitor "Please press refresh on each visit"
but if refreshing helps, it should just be a browser (thus client-side) cache....

There is no water proof solution to prevent caching on every browser and every situation, but with Expires, Last-Modified and cache-control headers it should be possible to prevent in many cases.
bas is offline
Reply With Quote
View Public Profile
 
Old 08-17-2008, 10:59 PM Re: How can I prevent the server side caching?
Truly's Avatar
Ultra Talker

Posts: 322
Trades: 0
Im no expert with caching but if you wait a bit Im sure you will get some good help with this issue. Until you do though, you can always force refresh the page.

This can be done through javascript or meta refresh. Im sure there is a better solution that one of the real experts on this site will give you but until you get that going you can use the forced refresh as a quick fix.
__________________
DVD Movie Release Database:
Please login or register to view this content. Registration is FREE
Truly is offline
Reply With Quote
View Public Profile
 
Old 08-18-2008, 11:20 AM Re: How can I prevent the server side caching?
Novice Talker

Posts: 10
Trades: 0
bas

I read about server-side cache in many pages on internet but still cannot find the solution.

Truly

I added this code in the header

<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="EXPIRES" CONTENT="Mon, 22 Jul 2002 11:12:01 GMT">

and many other similar lines BUT all didn't fix it

Any suggestions?
WMASTER is offline
Reply With Quote
View Public Profile
 
Old 08-18-2008, 12:41 PM Re: How can I prevent the server side caching?
bas
Super Talker

Posts: 108
Name: Bas
Trades: 0
What I actually meant where http-headers, for example with PHP: http://be.php.net/header

A post from that website:
Quote:
This is the Headers to force a browser to use fresh content (no caching) in HTTP/1.0 and HTTP/1.1:
PHP Code:
<?PHP 
header
'Expires: Sat, 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' ); 
?>
bas is offline
Reply With Quote
View Public Profile
 
Old 08-20-2008, 12:17 PM Re: How can I prevent the server side caching?
Novice Talker

Posts: 10
Trades: 0
Thanks bas, I will use this code but am afraid that I dont know where to add it becouse i have 2 header ...

/header.php
/language/english/html/skin/header.html

Site title and description and meta included in the first one "header.php"

This is the HEAD part:

PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><?php if($site_title!=""){echo strip_tags(preg_replace('/\015\012|\015|\012|"/s',' ',$site_title));}else{echo SITE_TITLE;}?></title>
<?php if($site_title!=""){echo preg_replace(array('/<meta name="keywords" content="(.*)">/Usi','/<meta name="description" content="(.*)">/Usi'),array('<meta name="keywords" content="'.strip_tags(preg_replace('/\015\012|\015|\012|"/s',' ',$site_title)).'">','<meta name="description" content="'.strip_tags(preg_replace('/\015\012|\015|\012|"/s',' ',$site_title)).'">'),META);}else{echo META;}?>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $CHARSET_OPTION;?>">
<?php 
if (!isset($css_file_dir)) {
$css_file_dir=HTTP_SERVER;
}
?>
<link rel="stylesheet" href="<?php echo $css_file_dir;?>css.php" type="text/css">
<?php
if (isset($extra_cssfile) && !empty($extra_cssfile)) {
echo 
"<link rel=\"stylesheet\" href=\"".$extra_cssfile."\" type=\"text/css\">";
}
if (!empty(
$jsfile)) {
echo 
"\n<script language=\"JavaScript1.1\" type=\"text/javascript\">";
echo 
"\n<!--\n";
include(
DIR_LANGUAGES.$language."/javascript_messages.php");
include(
DIR_JS.$jsfile);
echo 
"\n//-->\n</script>\n";
}
?>
</head>
<body dir="<?php echo $TEXTDIR_FORMAT;?>"<?php if(isset($body_onload)){echo " onLoad=\"".$body_onload."\"";}?>>
<!-- header //-->
<?php
if(!isset($bx_show_header) || $bx_show_header!="no") {
if(
$aff_menu==true){
@include(
DIR_SKIN.'header_affiliates.html');
}
elseif (
$_SESSION['userid']) {
@include(
DIR_SKIN.'header_jobseeker.html');
}
elseif(
$_SESSION['employerid'] || ((SIDE_ALIGN=="separated_left" || SIDE_ALIGN=="separated_right" || SIDE_ALIGN=="separated_top") && $empl_menu==true)){
@include(
DIR_SKIN.'header_employer.html');
}
else {
@include(
DIR_SKIN.'header.html');
}

?>
<!-- header_eof //-->
WMASTER is offline
Reply With Quote
View Public Profile
 
Old 08-20-2008, 12:34 PM Re: How can I prevent the server side caching?
bas
Super Talker

Posts: 108
Name: Bas
Trades: 0
It need to be before you print any content.
PHP Code:
<?php  
header
'Expires: Sat, 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' );  
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
...

Last edited by bas; 08-20-2008 at 12:37 PM..
bas is offline
Reply With Quote
View Public Profile
 
Old 08-21-2008, 04:35 PM Re: How can I prevent the server side caching?
Novice Talker

Posts: 10
Trades: 0
GREAT
It works very well now

Thank you so much for your help
WMASTER is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How can I prevent the server side caching?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.27136 seconds with 12 queries