473,387 Members | 1,365 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,387 software developers and data experts.

caching index.php file

Hi everyone! I have another weird question. I'm working on my site where the information won't be changing very often, and it's not horribly important that after a change that the information is currently available. With that said, I've started caching my sql calls as a JSON text file. This lead me to start thinking that maybe I should do that with my index file as well. Is there any real benefit to doing this? So instead of the user coming to my site and waiting for my server to do its looping and compiling, the file has already been cached and the markup is already available. I would think this would be faster but I can't imagine it being noticeable. Does anyone have any insight? Thanks!!
Apr 11 '11 #1
2 1298
Dormilich
8,658 Expert Mod 8TB
With that said, I've started caching my sql calls as a JSON text file.
are you sure this is actually faster?

So instead of the user coming to my site and waiting for my server to do its looping and compiling, the file has already been cached and the markup is already available.
that essentially depends on how fast the compiling is. if it is, say, under 500 ms (which is quite long for a script), caching is not worth the effort (the transfer time (Request + Response) is usually some 100 ms). however, the more visitors you have per hour, the more useful caching can be.
Apr 13 '11 #2
dgreenhouse
250 Expert 100+
First off... Sending plain HTML is always going to be
faster than processing database records.

If the information really doesn't change that often,
why don't you just generate an HTML page and feed that
to the visitors?

You could check the generation date/time of the HTML
file and regenerate from the database if the generation
date/time is older than some defined value.

{ You could even use matches in an .htaccess file to do
the caching check and either feed a pre-generated HMTL
file or invoke the index.php script if generation is required. }

Just a thought...


Some pseudo code for checking inside of an index.php file...
Expand|Select|Wrap|Line Numbers
  1. 0- Entry point of index.php
  2.  
  3. 1- Check file time of index.html
  4.  
  5. 2- If time is within the defined caching time,
  6. feed the current index.html to the browser.
  7.  
  8. 3- If time is older, regenerate the index.html using
  9. buffering, output to the browser, and overwrite the index.html file
  10. (Ensuring that only one visitor's request is overwriting
  11. the HTML file can be a little tricky and would more than
  12. likely require some type of semaphore or temp file to
  13. real file switch, but it's doable.)
  14.  
Apr 13 '11 #3

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

Similar topics

0
by: Oswaldo Castro | last post by:
------=_NextPart_000_000D_01C34B95.4BFBA860 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi Everybody I have acidentally deleted an index file...
0
by: Jean Hagen | last post by:
I'm trying to write a script to weekly remove MySQL logs, the general, error and binary log files. Following the MySQL documentation, I've written a script that moves all current log files, then...
2
by: Hervé Piedvache | last post by:
Bug or problem with PostgreSQL ? version --------------------------------------------------------------- PostgreSQL 7.4.3 on i686-pc-linux-gnu, compiled by GCC 2.95.4 select * from my_table;...
0
by: baldwin | last post by:
Hi, I am trying different caching features of asp.net. I came to a point that I want to cache the content in a master file. Is it possible to cache the contents in Master File? User controls can...
5
by: Raj | last post by:
What is the purpose of file system caching while creating a tablespace? Memory on the test server gets used up pretty quickly after a user executes a complex query(database is already activated),...
0
by: suryanector | last post by:
anybody knows source code for programs using Index file, inverted file operations, usage of B and B++ trees in C++ language plz send them.
2
by: nishac | last post by:
I want to search for a keyword from the .txt and .pdf files stored in different directories.So i would require to index the file.right?Can anyone help me to to do the indexing?
1
by: w33d5 | last post by:
I'm looking for a little help in making an index file to read the subdirectories in the same folder and display the links in a table. i am loading photo galleries using google's picasa onto my...
1
by: veer | last post by:
hi it looks a silly question but i m getting confused actually i want to copy folders from one location to another like from C:\abc To D:\xyz here abc and xyz are two folders in c and d drive it...
10
by: beary | last post by:
Hello all, I've done something a bit stupid and am hoping some kind soul out there can help me out. There's a piece of code that goes through and creates a high number of subdirectories within...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.