亚洲精品久久久久久第一页-人妻少妇精彩视品一区二区三区-91国产自拍免费视频-免费一级a在线播放视频正片-少妇天天日天天射天天爽-国产大屁股喷水视频在线观看-操美女骚穴抽插性爱视频-亚洲 欧美 中文字幕 丝袜-成人免费无码片在线观看

php使用GD生成圖片并且加入瀏覽器緩存

  最近很多人使用php的GD庫生成圖片,但是有些人不知道加緩存,導致服務(wù)器壓力很大,所以今天介紹關(guān)于php中GD庫生成圖片并且加入緩存
 

php使用GD生成圖片并且加入瀏覽器緩存

文章插圖
 
    生成圖片代碼:
<?php$width = 300;$height = 300; $im = imagecreatetruecolor($width,$height);$white = imagecolorallocate($im,255,255,255);$blue = imagecolorallocate($im,0,0,64); imagefill($im,0,0,$blue);imageline($im,0,0,$width,$height,$white);imagestring($im,4,80,150,"Shrimpking Study PHP",$white); //中文會出現(xiàn)亂碼,目前還沒有學習會header("Content-type:image/png");imagepng($im);imagedestroy($im);?>新增瀏覽器頭部緩存,即加入以下代碼:
//開啟緩存session_start(); header("Cache-Control: private, max-age=10800, pre-check=10800");header("Pragma: private");header("Expires: " . date(DATE_RFC822,strtotime(" 2 day")));   完整的:
<?php$width = 300;$height = 300; $im = imagecreatetruecolor($width,$height);$white = imagecolorallocate($im,255,255,255);$blue = imagecolorallocate($im,0,0,64); imagefill($im,0,0,$blue);imageline($im,0,0,$width,$height,$white);imagestring($im,4,80,150,"Shrimpking Study PHP",$white); //中文會出現(xiàn)亂碼,目前還沒有學習會header("Content-type:image/png");imagepng($im);imagedestroy($im);//開啟緩存session_start(); header("Cache-Control: private, max-age=10800, pre-check=10800");header("Pragma: private");header("Expires: " . date(DATE_RFC822,strtotime(" 2 day")));?>


    以上關(guān)于本文的內(nèi)容,僅作參考!溫馨提示:如遇健康、疾病相關(guān)的問題,請您及時就醫(yī)或請專業(yè)人士給予相關(guān)指導!

    「愛刨根生活網(wǎng)」www.malaban59.cn小編還為您精選了以下內(nèi)容,希望對您有所幫助: