473,382 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

cache dynamic page

dlite922
1,584 Expert 1GB
Hey guys,

I've seem to forgotten how to cache a php page so that when the a link is clicked the dynamic content is only grabbed from the DB only once a day.

every Google results point to /not/ caching.

I've got caching enabled so that now my back/forward browser button do not regenerate the page.

FYI: It's a report that takes a long time to regenerate.

Other pages on my site, the search and filter pages, those should not cache anything, so whatever solution, it must apply to specific pages.


Code:
Expand|Select|Wrap|Line Numbers
  1.  
  2. $secondsToMidnight = (strtotime('midnight')+86400)-time();
  3. header("Pragma: public");
  4. header("Cache-Control: maxage=$secondsToMidnight"); // HTTP/1.1
  5. header("Expires: " . date('r',time()+$secondsToMidnight)); // Date in the past
  6.  
  7.  
Besides saving the output buffer to a file, is there any other way to force PHP/FF Browser to keep the same output.

Thanks,




Dan
Feb 19 '10 #1
10 2065
Dormilich
8,658 Expert Mod 8TB
you mean something like Memcache?
Feb 19 '10 #2
dlite922
1,584 Expert 1GB
Yes, from the description of it, it looks like that's along the lines of what i'm looking for, but not a PECL installation. I'm working with php 5.1.6 core only.

Thanks,


Dan
Feb 19 '10 #3
dlite922
1,584 Expert 1GB
If anybody else is following this, here's what i'm looking into

http://www.databasejournal.com/featu...uery-Cache.htm

Cheers



Dan
Feb 19 '10 #4
Dormilich
8,658 Expert Mod 8TB
AFAIK, there is no built-in caching in PHP, although APC might make it into PHP 6. (ref)

http://www.databasejournal.com/featu...uery-Cache.htm
have you thought about Prepared Statements?
Feb 19 '10 #5
kovik
1,044 Expert 1GB
Search engines perform particular searches once every so often, and then save the results into another database table for easy access. Maybe you'd be interested in that technique?
Feb 19 '10 #6
Dormilich
8,658 Expert Mod 8TB
that’s like session storage in a DB …
Feb 19 '10 #7
Markus
6,050 Expert 4TB
You could just perform the cache yourself? Saving the content to a static .html file , checking on page load whether it needs to be updated.
Feb 19 '10 #8
kovik
1,044 Expert 1GB
@Markus: I thought that's what the PHP cache apps did. I've never tried any, though.
Feb 19 '10 #9
dlite922
1,584 Expert 1GB
Ya Markus, that's one route I was considering too since I can't get MySQL cache to work on this server.

The Database schema is not mine (it's another systems) so adding tables is not an option unless I create a separate database. I don't want to get into double database situation just for caching.

@Kovik, what do you mean by PHP cache apps? like Smarty? Ya, that would work, but it will require change to my framework. It's not an "insert header/footer" method but a "insert dynamic content" one.

Conclusion: Save static.html file in a /tmp folder for now.

Thanks guys,







Dan
Feb 22 '10 #10
Markus
6,050 Expert 4TB
@kovik
I have no idea about Memcache, but APC caches PHP's opcodes.
Feb 22 '10 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Nadav | last post by:
Hi, I am new to WebControls, I have created a WebControl that is used to present an image, the image bing presented is created on runtime, each client side button click causes the image to...
7
by: moondaddy | last post by:
I have a products catalogue that I'm putting online and there will be between 20 to 50 different pages of products. Each page contains a datagrid of products for a given category. However, the...
4
by: sviau | last post by:
should cache-control be set to public or private on dynamic site. our content doesnt change for 24hrs, but because results from search pages vary so much, we cant cache the pages themselves. ...
2
by: Just D. | last post by:
All, Can we enable/disable the cache for each control separately or it's a global feature for the whole page? I'm aware of many settings and some bugs regarding cache but I've never seen...
6
by: Stephane | last post by:
Hi, All images on my ASP.Net web site are reloaded almost each time I visit a page. My chache setting on IE is set to Automatically. When I visit another web site, images are rarely reloaded so...
2
by: Quasar | last post by:
Hi Gents, I'm trying to tune our DBs using the Desing Advisor feature. I'm interested just in the indexes area. Following the IBM infocenter I came to this page:...
3
by: aj | last post by:
DB2 LUW 8.1 fixpak 14 Red Hat EL AS 4.4 I'm trying to diagnose some nocturnal CPU pressure, and am trying to understand the dynamic statement cache as it applies to LUW. The only doc/redbooks...
1
by: WT | last post by:
Hello, I have a dictionary made with objects which contain a control element, the control element is added to a Page when I want to edit the dictionary content. I put this dictionary in cache...
2
by: Damir | last post by:
Hello! I have noticed that after (sucessfully) executing the command: FLUSH PACKAGE CACHE DYNAMIC the dynamic SQL statement cache is not completely cleared (some of the dynamic SQL statement...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.