Webmaster Forum

Go Back   Webmaster Forum > Web Development > Web Hosting Forum > Dedicated Servers

Dedicated Servers Dedicated server help.


Closed Thread
 
Thread Tools Display Modes
Share |
  #1  
Old 06-27-2013, 06:47 AM
msankaroo7's Avatar
msankaroo7 msankaroo7 is offline
Junior Member
 
Join Date: 06-22-13
Posts: 13
iTrader: 0 / 0%
How to create server Cache for static page

I developed thequotes.net website. Now i want to create server cache for this site to avoiding overload and easy to load. Hi, i am not sure about this topic so anyone explain step by step how to create cache and then how to make changes in cache. share your ideas and suggestions. And also not sure about servers.
 

Advertisement

Advertisement

  #2  
Old 06-27-2013, 03:36 PM
HTMLBasicTutor's Avatar
HTMLBasicTutor HTMLBasicTutor is offline
Administrator
 
Join Date: 10-29-07
Location: Canada
Posts: 26,707
iTrader: 5 / 100%
What are you using to run the site?
 
  #3  
Old 06-28-2013, 04:50 AM
msankaroo7's Avatar
msankaroo7 msankaroo7 is offline
Junior Member
 
Join Date: 06-22-13
Posts: 13
iTrader: 0 / 0%
Quote:
Originally Posted by HTMLBasicTutor View Post
What are you using to run the site?
Host:Bluehost
Server: Apache http server(not sure)
Developed: PHP&mysql
 
  #4  
Old 06-28-2013, 10:12 AM
Cloudrck Cloudrck is offline
Junior Member
 
Join Date: 06-12-13
Posts: 45
iTrader: 0 / 0%
Quote:
Originally Posted by msankaroo7 View Post
Host:Bluehost
Server: Apache http server(not sure)
Developed: PHP&mysql
Than you need to use caching via your PHP script. Who developed it, how is HTML being displayed, template engine or custom scripting?
 
  #5  
Old 06-28-2013, 10:50 AM
ScriptMan's Avatar
ScriptMan ScriptMan is online now
Super Moderator
 
Join Date: 02-10-07
Location: Central Kentucky
Posts: 14,022
iTrader: 4 / 100%
Caching is a fairly simple addition to any php page that outputs html. Setting up and controlling the cached page life may be the most daunting part. Second hardest is the page name when using a dynamic script to create pages.

This is a very simple sample of caching what is page that has the same name every time but does contain dynamic content. At the top of your script you need:

PHP Code:
if ($cache=="on")
    {    
        
$cachefile "cache/index.html"// static here dynamic on most other pages
        // Serve from the cache if it is younger than $cachetime (set value in config)
        
if (file_exists($cachefile) && (time() - $cachetime filemtime($cachefile))) 
      {
        include(
$cachefile);
        echo 
"<!-- Cached ".date('F j, Y, g:i a'filemtime($cachefile))." --> ";  //optional
        
exit;
      }
        
ob_start(); // if the page is not in the cache start the output buffer
        
    

Caching on or off is set in your config file or specified at the top of the page. What this portion does is check to see if a cached file exists and if the timeout is still valid. If the cached file is still within the time set the cached page is served and the script terminates.

If your cached page was not found or is out time life then your scripted page executes normally. Then you have your normal page as it already exist. At the very bottom of your page you add this:

PHP Code:
if ($cache=="on")
    {    
        
$fp fopen ($cachefile'w');  // open the cache file for writing
        
fwrite($fpob_get_contents()); // save the contents of output buffer to the file
        
fclose($fp);  // close the file
        
ob_end_flush(); // Send the output to the browser
    

This bottom portion creates the the HTML file that will be served the next time (and for as long as you have specified its life to be). The script executes the file write and then sends the output to the browser.

Now having taken the time to share all that with you, Caching does not always speed up the page load. Some servers take longer to find and display a static file than they do to yield a dynamic page. I have the code in my scripts but I have it turned off at the current time.
 
  #6  
Old 06-29-2013, 06:03 AM
msankaroo7's Avatar
msankaroo7 msankaroo7 is offline
Junior Member
 
Join Date: 06-22-13
Posts: 13
iTrader: 0 / 0%
Quote:
Originally Posted by Cloudrck View Post
Than you need to use caching via your PHP script. Who developed it, how is HTML being displayed, template engine or custom scripting?
thanks for reply. yes i need in php script only.
 
  #7  
Old 07-20-2013, 04:11 AM
RH-Calvin RH-Calvin is offline
Banned
 
Join Date: 06-05-13
Location: Christopher
Posts: 23
iTrader: 0 / 0%
You can use a web server module such as apache mod_cache if your hosting allows installation or modification of the web server.
 
  #8  
Old 08-22-2013, 06:20 PM
ultimatehostings's Avatar
ultimatehostings ultimatehostings is offline
Junior Member
 
Join Date: 08-22-13
Location: India
Posts: 22
iTrader: 0 / 0%
You're on a shared server so there's nothing much you can do as you do not have server side access, you would need a VPS or a dedicated server to implement any server side modifications.
 
Go Back   Webmaster Forum > Web Development > Web Hosting Forum > Dedicated Servers

Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create RSS feeds for static pages? smartware SEO Forum 7 02-06-2012 02:57 AM
Best cache time life for a semi-static site? ScriptMan Coding Forum 2 01-14-2012 07:09 AM
Ready to Set A Static Page for Homepage....How to move blog posts to another page? rookiethomas Blogging Forum 2 09-21-2009 01:04 PM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 10:51 AM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC