このページでGoogleのPageSpeedツールを実行しました: http ://classifieds.your-adrenaline-fix.com/detail.php?fatherID = 10&ListingID = 7&TypeID = 42
結果は、キャッシュバリデーター(Last-ModifiedまたはETagヘッダー)を指定する必要があることを示しています。
私はこれを完全に読みました: https ://developers.google.com/speed/docs/best-practices/caching#LeverageProxyCaching
しかし、私は何をすべきかわかりません。
私が経験している問題(GoogleのPageSpeedツールを介して発生している)は、Googleマップを表示する次のコードに起因していることを知っていますが、このコードはここの誰かが私を助けてくれたコードです。(私はまだPDOについて何も学んでおらず、コードを本当に理解していませんが)
誰かが以下に提供されているコードを調べて、すべてが正しいように見えることを知らせ、Googleのページ速度の推奨に従ってページを改善するためにキャッシュバリデーターを指定する方法を教えてくれることを願っています。
どんな助けでも確かにありがたいです、そして私は前もってすべてに感謝します。
スチュアートK
編集:さらに、.htaccess内に次のコードがあります:(次のマップコードを使用)
<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default directive
ExpiresDefault "access plus 1 year"
# Favicon
ExpiresByType image/x-icon "access plus 1 year"
# Images
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
# CSS
ExpiresByType text/css "access 1 month"
# Javascript
ExpiresByType application/javascript "access plus 1 year"
</IfModule>
$TypeID = isset($_GET['TypeID']) ? $_GET['TypeID'] : '';
$ListingID = isset($_GET['ListingID']) ? $_GET['ListingID'] : '';
$allowed_tables = array('tt_42', 'tt_43');//Array of allowed tables to sanatise query
//Define table name
$table ="tt_".$TypeID;
//Connect to database
$dbh = new PDO("mysql:host=$host;dbname=$db", $username, $password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
try {
//Check if table name is in allowed list
if (in_array($table, $allowed_tables)) {
//Prepare query
$query = "SELECT * FROM `$table` WHERE `ID` = ? AND `ExpireDate` > NOW()";
}//end if
// Prepare statement
$stmt = $dbh->prepare($query);
// Assign parameter
$stmt->bindParam(1,$ListingID);
//Execute query
$stmt->setFetchMode(PDO::FETCH_ASSOC);
$stmt->execute();
//New code
$Address = $listing['Address'];
$City = $listing['City'];
$State = $listing['State/Province'];
$Zip = $listing['Zip/Postal'];
$Country = $listing['Country'];
//End new code
echo '<h2>Map of Surrounding Area With Navigational Aides</h2>';
echo '<div class="CalloutBoxBlue">Hover over map and scroll, or use + and - in LH corner of map to zoom or expand viewing area. Alternatively, hold down mouse to manually move the map to a different geographical location, or drag the person icon to a specific location on the map for a street view.</div>';
echo '<div id="GoogleMap">';
//New code
echo '<iframe scrolling="no" style="width:480px; height:300px; border:0px;" frameborder="0" src="googlemap.php?Address='.$Address.'&City='.$City.'&State='.$State.'&Zip='.$Zip.'&Country='.$Country.'"></iframe>';
//End new code
echo '</div>';
}//End try
catch(PDOException $e) {
echo "I'm sorry I'm afraid you can't do that.". $e->getMessage() ;// Remove or modify after testing
file_put_contents('PDOErrors.txt',date('[Y-m-d H:i:s]').", mapSelect.php, ". $e->getMessage()."\r\n", FILE_APPEND);
}
}