Hi guys,
Let's say I have a page that is primarily HTML but I added a few small parts
that are PHP, for example a random banner. The page is in no way PHP driven,
it just has some some random stuff like the banner and/or a tip of the day.
What bothers me is that the PHP page won't be cached, so if the page has a
lot of links and, on average, the user clicks ten links (hitting the back
button after he does that) my bandwidth usage increases tenfold.
I think I can send cache headers but I don't know much about them. Is it
possible to set it for, say, an hour so that if he hits the back button
he'll get the same banner/tip of the day that he originally got (because
he's looking at his cached page) and only after an hour will he get a new
random banner/tip ?
I'm ready to switch my pages to PHP but I don't want to get a huge bandwidth
bill.
Any guidence would be appreciated.
Take care,
Cyrus 9 2102
>Let's say I have a page that is primarily HTML but I added a few small parts that are PHP, for example a random banner. The page is in no way PHP driven, it just has some some random stuff like the banner and/or a tip of the day.
Can't you turn the URL that returns the *BANNER* into a PHP one,
and leave the main page alone? (The PHP selects a random image,
then returns appropriate headers and the body of the image, probably
with fpassthru()). You get 10 image hits (maybe that's what you
want) but only one hit on the main page. You could also try letting
the browser cache the images with cache headers, but I'm not sure
you want to.
What bothers me is that the PHP page won't be cached, so if the page has a lot of links and, on average, the user clicks ten links (hitting the back button after he does that) my bandwidth usage increases tenfold.
I think I can send cache headers but I don't know much about them. Is it possible to set it for, say, an hour so that if he hits the back button he'll get the same banner/tip of the day that he originally got (because he's looking at his cached page) and only after an hour will he get a new random banner/tip ?
I'm ready to switch my pages to PHP but I don't want to get a huge bandwidth bill.
Gordon L. Burditt
Cyrus D. wrote: Hi guys,
Let's say I have a page that is primarily HTML but I added a few small parts that are PHP, for example a random banner. The page is in no way PHP driven, it just has some some random stuff like the banner and/or a tip of the day.
What bothers me is that the PHP page won't be cached, so if the page has a lot of links and, on average, the user clicks ten links (hitting the back button after he does that) my bandwidth usage increases tenfold.
I think I can send cache headers but I don't know much about them. Is it possible to set it for, say, an hour so that if he hits the back button he'll get the same banner/tip of the day that he originally got (because he's looking at his cached page) and only after an hour will he get a new random banner/tip ?
I'm ready to switch my pages to PHP but I don't want to get a huge bandwidth bill.
Any guidence would be appreciated.
This example at http://butterflies.usenetshit.info/butterfly.phps has the
stuff you need for setting the modification dates and times and telling the
browser to use the cached version where appropriate etc. I've used a
modified version of the code in that page in both PHP and ASP and it worked
nicely.
--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Hi Gordon,
Let's just say it's text for a random tip of the day. If I make a seperate
PHP file (URL) to return the random tip how do I link it up to my main page
?
Tip.php
<?php
function GetTip(){
//returns a string
}
?>
Main.php
lots of HTML
the tip goes here
more HTML
Sorry if I seem like a newbie.
Thanks,
Cyrus
Cyrus D. schrieb: Tip.php
<?php function GetTip(){ //returns a string } ?>
Main.php
lots of HTML the tip goes here more HTML
Main.php
lots of HTML
<?php
include('Tip.php');
$result = GetTip();
echo ($result);
?>
more HTML
Matthias
Cyrus D. wrote: Let's say I have a page that is primarily HTML but I added a few small parts that are PHP, for example a random banner.
You already said that, in another thread. And I already answered you, in
that thread. Did you not like my responses?
The page is in no way PHP driven, it just has some some random stuff like the banner and/or a tip of the day.
I'm not sure what you mean by this. If the page is parsed by php, then
it is php driven. Perhaps you mean that only a small part of the content
is created by php, but that only affects server processing time needed.
It is unrelated to http caching.
What bothers me is that the PHP page won't be cached,
Well, sort of. It means that the php page will not have last-modified
headers, so conditional get requests are impossible. (Didn't I explain
this adequately in the previous thread?)
so if the page has a lot of links and, on average, the user clicks ten links (hitting the back button after he does that) my bandwidth usage increases tenfold.
It depends on the browser settings, but this is certainly possible.
I think I can send cache headers but I don't know much about them. Is it possible to set it for, say, an hour so that if he hits the back button he'll get the same banner/tip of the day that he originally got (because he's looking at his cached page) and only after an hour will he get a new random banner/tip ?
Yes, using php's header function.
header("Cache-Control: max-age=3600");
This sends a response header to the client, as follows,
Cache-Control: max-age=3600
which tells the client that the resource is cacheable, and will be fresh
for 3600 seconds or 1 hour.
I'm ready to switch my pages to PHP
Why? Unless php is doing something critical for the page content, why
not stick with static html? ISTM that you should think about the user.
The user does not need a random banner. So unless that banner is
generating significant revenue, I'd dump the idea. If it is important,
then G. Burditt's idea may be worth exploring. Use a url for the image,
say /image/random.php, and have that url return a random image resource.
That way, the html document that includes that image can remain a static
resource, with all the benefits of http caching (hopefully!) built-in
via Apache.
As for "tip of the day", if that really is what you claim it is, and it
really changes every day, make the page fresh for that day. You may need
to look at the http 1.0 expires header instead. But without details, I
cannot offer you anything more specific.
but I don't want to get a huge bandwidth bill.
If the site is popular, then caching becomes quite critical.
--
Brian (remove "invalid" to email me)
Brian wrote: What bothers me is that the PHP page won't be cached,
Well, sort of. It means that the php page will not have last-modified headers, so conditional get requests are impossible. (Didn't I explain this adequately in the previous thread?)
I'm not sure what you posted in the previous thread so this may cover some
of that as well. You can set last-modified headers with PHP but it's a
little more work than either not doing it, or letting the webserver take
care of it with static HTML files.
I have used this method in a couple of different sites (in both PHP and ASP)
and am going to create a function or class to simplify the process so I can
easily incorporate it into my other projects and will publish it on my
website when it's done.
Anyway, I won't explain it just now but instead point you to the example
code where I found it at http://butterflies.usenetshit.info/butterfly.phps
Hopefully I should have a nice function written by early next week and will
share my version of Brucie's code at that point. (Brucie's the author of
the above script).
--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Matthias Esken wrote: Cyrus D. schrieb:
Tip.php
<?php function GetTip(){ //returns a string } ?>
Main.php
lots of HTML the tip goes here more HTML
Main.php
lots of HTML <?php include('Tip.php'); $result = GetTip(); echo ($result); ?> more HTML
However, that doesn't solve the caching problem as described. If you're
worried about that side of it, you may want to generate the tip as an
image using GD or something and save it to disk - after all, it's "tip
of the day", not "tip of the request" right? ;) Otherwise, I would say
that the overhead of processing the image for every request may not be
be worthwhile... could just put the tip into an iframe and have that
point to a php script that spits it out I guess..
--
Justin Koivisto - sp**@koivi.com http://www.koivi.com
Chris Hope wrote: You can set last-modified headers with PHP but it's a little more work than either not doing it, or letting the webserver take care of it with static HTML files.
I have used this method in a couple of different sites (in both PHP and ASP) and am going to create a function or class to simplify the process so I can easily incorporate it into my other projects and will publish it on my website when it's done.
Already done in php: http://simon.incutio.com/archive/200...conditionalGet
I use a version of that script, modified a bit to do a real time
comparison instead of string matching.
--
Brian (remove "invalid" to email me)
Brian wrote: Chris Hope wrote:
You can set last-modified headers with PHP but it's a little more work than either not doing it, or letting the webserver take care of it with static HTML files.
I have used this method in a couple of different sites (in both PHP and ASP) and am going to create a function or class to simplify the process so I can easily incorporate it into my other projects and will publish it on my website when it's done.
Already done in php:
http://simon.incutio.com/archive/200...conditionalGet
I use a version of that script, modified a bit to do a real time comparison instead of string matching.
Excellent, thanks. Saves me having to do it myself.
--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Tony Marston |
last post by:
If the use of the browser's BACK button is interfering with the operation of
your web application then take a look at this article entitle "Back...
|
by: Michael G |
last post by:
Can the browser back button or browser caching be turned on or off via php?
Thanks, Mike
----== Posted via Newsfeeds.Com -...
|
by: R. Ian Lee |
last post by:
I have an ASP.NET page that spawns a popup window using
javascript's window.open. This works fine. It pops up,
you enter some data, press save...
|
by: Ken Varn |
last post by:
Is there anyway within my web application that I can have all browser
caching turned off for all aspx pages sent by my IIS server? I need to have...
|
by: lanem |
last post by:
I am working on a ASP.NET 2.0 web site that has some PDFs that users can
download. I'm using an HTTP module to see if the user has permission to...
|
by: nsimeonov |
last post by:
Hello,
Does anyone have any idea how Gmail does this? I have a web application
and people complain sometimes about some problems and most of...
|
by: jlotmar |
last post by:
I am currently experiencing a problem whereby browser caching seems to be
causing my page to be invalid.
I am using a standard DataGrid...
|
by: bvdb |
last post by:
Hello,
my web-application uses two frames, one with a list of database
records, one with a record detail view. From the detail view there is...
|
by: Ian Semmel |
last post by:
Is there a way to get the Page_Load event to fire if the user clicks the
Back button on the browser rather than clicking a hyperlink ?
|
by: tammygombez |
last post by:
Hey fellow JavaFX developers,
I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
|
by: tammygombez |
last post by:
Hey everyone!
I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
|
by: teenabhardwaj |
last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
|
by: CD Tom |
last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
|
by: CD Tom |
last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
| |