Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
Thread Tools Display Modes
Share |
  #1  
Old 10-13-2014, 09:30 AM
deanduke deanduke is offline
Junior Member
 
Join Date: 10-13-14
Posts: 19
iTrader: 0 / 0%
htaccess and cache-control

Hello, I've a question.

My hosting updated its servers, using the old server I was able to use cache-control directive, with the new server I'm not able any more (if I put the cache-control code in the htaccess I obtain a 500 error).

I've told the hosting about that and it's reply was:

"with the new apache/php version using this header is senseless, you need to implement the function in the pages of your website".

Using phpinfo() function I see Server API is Apache 2.0 Handler and PHP version is PHP Version 5.5.12-2ubuntu4 .

What the hosting reply means? Is it true that with those apache/php versions I should avoid to use cache-control?

Thanks.
 
Reply With Quote

Advertisement

Advertisement

  #2  
Old 10-13-2014, 12:54 PM
ScriptMan's Avatar
ScriptMan ScriptMan is online now
Super Moderator
 
Join Date: 02-10-07
Location: Central Kentucky
Posts: 13,875
iTrader: 4 / 100%
I've never done it with Apache so I can't answer that.

Doing it with PHP at the page level is only a few lines of code added to the top of each script. That I may be able to help you with if you want to learn.
 
Reply With Quote
  #3  
Old 10-14-2014, 03:06 AM
deanduke deanduke is offline
Junior Member
 
Join Date: 10-13-14
Posts: 19
iTrader: 0 / 0%
Hi ScriptMan, txs for the hint.
Which PHP script would you use to make cache?
 
Reply With Quote
  #4  
Old 10-14-2014, 05:26 AM
ScriptMan's Avatar
ScriptMan ScriptMan is online now
Super Moderator
 
Join Date: 02-10-07
Location: Central Kentucky
Posts: 13,875
iTrader: 4 / 100%
If there is a particular script I am not aware of it. There are examples out there on the web and you have to piece together what you want. Let me explain the process. Then you tell me about how your site is built and I will offer some code for you.

Exactly what code is used at the top of you page will vary depending on how the HTML and queries are being generated.

The caching process involves only 2 section of code. One goes at the top of each and every dynamic page and does a simple check to see:
* if the page exists in the cache file folder and if it is new enough (based on time factor you set) to use
* Serves that page if it exist and is timely
* terminates the rest of the scripts on the page
* or allows the rest of the page to execute

If the page is being regenerated then it writes the HTML rendered to an output buffer so that at the bottom of the page:
*the contents of the buffer file are named and
*the data is written to a file that identifies the page
*the output buffer is cleared.

In my usage that part of the code is fairly standard and is placed after the closing </HTML> tag on the script.

PHP Code:
<?PHP
    
if ($cache=="on")
    {    
        
$cachefile "cache/".$page;
        
$fp fopen($cachefile'w');
        
fwrite($fpob_get_contents());
        
fclose($fp);
        
ob_end_flush(); 
    }
?>
I do think I should point out that caching may decrease the processing load on a busy server but it may take longer to find and serve the file than serving it dynamically. This depends on the total number of queries per rendered page and the input output disc speed.
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


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
[.htaccess] directory-specific cache-control AVanover5 Coding Forum 1 03-12-2011 07:10 AM
Good Reason For Population Control (Birth Control) Allen Farlow Controversial Social Issues 11 02-19-2010 09:27 AM
Conflict, What is the right htaccess rule, default homepage file with htaccess? basketmen Coding Forum 2 01-20-2009 08:50 AM


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


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