久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      PHP實(shí)現(xiàn)頁(yè)面靜態(tài)化、純靜態(tài)化及偽靜態(tài)化

      PHP實(shí)現(xiàn)頁(yè)面靜態(tài)化、純靜態(tài)化及偽靜態(tài)化

      概念

      PHP靜態(tài)化分為:純靜態(tài)化 和 偽靜態(tài)化;

      純靜態(tài)化又分為:局部靜態(tài)化 和 完全靜態(tài)化

      純靜態(tài)化:是把PHP生成的動(dòng)態(tài)頁(yè)面保存成靜態(tài)的html文件,用戶訪問(wèn)該靜態(tài)頁(yè)面,而不是用戶每一次訪問(wèn)都重新生成一張相同的網(wǎng)頁(yè),優(yōu)點(diǎn)就是減小服務(wù)器開銷,

      局部靜態(tài)化:是生成的靜態(tài)文件中,有局部的數(shù)據(jù)還是通過(guò)ajax技術(shù)動(dòng)態(tài)獲取的;

      完全靜態(tài)化:即不存在動(dòng)態(tài)獲取數(shù)據(jù)的情況,所以內(nèi)容都來(lái)自靜態(tài)的html頁(yè)面

      偽靜態(tài)化:Apache服務(wù)器rewrite配置

      純靜態(tài)化的實(shí)現(xiàn)

      利用php內(nèi)置的ob函數(shù)實(shí)現(xiàn)頁(yè)面的靜態(tài)化,大概步驟如下:

      <?php ob_start();//開啟緩存  ?> <p>我是要生成的靜態(tài)內(nèi)容,也可以在該處鏈接數(shù)據(jù)庫(kù)生成動(dòng)態(tài)內(nèi)容于此</p> <?php  file_put_contents( 'index.html', ob_get_clean() );//把生成的靜態(tài)內(nèi)容保存到index.html文件,而不是輸出到瀏覽器 ?>

      觸發(fā)系統(tǒng)生成純靜態(tài)化頁(yè)面

      方法:頁(yè)面添加緩存時(shí)間;手動(dòng)觸發(fā)

      頁(yè)面添加緩存時(shí)間

      <?php $file_name = 'index.html'; if(file_exists( $file_name ) &&  filemtime( $file_name ) - time() < 10 ){//如果文件是存在并且最后修改時(shí)間小于設(shè)定時(shí)間 10s     //filemtime( $file_name );//得到文件最后修改時(shí)間     //time();//當(dāng)前時(shí)間     require_once( $file_name );//引入文件 }else{  ob_start( );  ?> <p>我是要生成的靜態(tài)內(nèi)容</p>  <?php file_put_contents( $file_name,  ob_get_contents() )//輸出到瀏覽器 }

      如果后臺(tái)數(shù)據(jù)存在更細(xì),定時(shí)刷新不能及時(shí)更改靜態(tài)頁(yè)面,怎么辦?所有引入了手動(dòng)觸發(fā)的功能

      Linux下的crontab定時(shí)掃描程序

      */5****php/data/static/index.php

      PHP偽靜態(tài)

      Apache服務(wù)器rewrite配置

      在httpd.conf文件中,找到

      #注釋:去掉前邊的" # "開啟rewrite服務(wù),重啟服務(wù)器生效
      #LoadModule rewrite_module modules/mod_rewrite.so
      #注釋:http-vhosts.conf文件是虛擬域名配置的文件,開啟改文件可以配置虛擬域名,一般默認(rèn)是開啟的
      #Include conf/extra/httpd-vhosts.conf

      rewrite偽靜態(tài)配置

      <VirtualHost *:80>     ServerAdmin webmaster@dummy-host.example.com     DocumentRoot "c:/Apache24/docs/dummy-host.example.com"     ServerName dummy-host.example.com     ServerAlias www.dummy-host.example.com     ErrorLog "logs/dummy-host.example.com-error.log"     CustomLog "logs/dummy-host.example.com-access.log" common     #配置規(guī)則如下所示     RewriteEngine on     RewriteRule ^/vidio/([0-9]*).html$ /vidio.php?id=$1      </VirtualHost>

      也可用.htacess文件,放在網(wǎng)站目錄下,無(wú)需重啟服務(wù)器。

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)