tag:blogger.com,1999:blog-865923359735383241.post6698226975826038676..comments2023-10-29T07:27:09.012-06:00Comments on Ccna final exam - java, php, javascript, ios, cshap all in one: Set HTTP Caching Expiration, Recommended by Google PageSpeedUnknownnoreply@blogger.comBlogger2125tag:blogger.com,1999:blog-865923359735383241.post-7716937026760301562012-06-10T21:14:07.404-06:002012-06-10T21:14:07.404-06:00It can be done with both htaccess and php. Typical...It can be done with both htaccess and php. Typically you wouldn't want to force caching the actual html since its dynamic database driven content (it can be done with the header() php function if needed). What you want to cache is external css & javascript, and image files.<br /><br />See here for an .htaccess solution: http://www.askapache.com/htaccess/apache-speed-expires.htmlUserhttps://www.blogger.com/profile/11557173689529910046noreply@blogger.comtag:blogger.com,1999:blog-865923359735383241.post-51287119669346644972012-06-10T21:14:05.056-06:002012-06-10T21:14:05.056-06:00In your root's .htaccess:
<IfModule mod_ex...In your root's .htaccess:<br /><br /><IfModule mod_expires.c><br /> ExpiresActive On<br /> ExpiresDefault "access plus 1 seconds"<br /> ExpiresByType image/x-icon "access plus 2592000 seconds"<br /> ExpiresByType image/jpeg "access plus 2592000 seconds"<br /> ExpiresByType image/png "access plus 2592000 seconds"<br /> ExpiresByType image/gif "access plus 2592000 seconds"<br /> ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"<br /> ExpiresByType text/css "access plus 604800 seconds"<br /> ExpiresByType text/javascript "access plus 216000 seconds"<br /> ExpiresByType application/x-javascript "access plus 216000 seconds"<br /> ExpiresByType text/html "access plus 600 seconds"<br /> ExpiresByType application/xhtml+xml "access plus 600 seconds"<br /></IfModule><br /><br /><br />And follow by:<br /><br /><IfModule mod_headers.c><br /><FilesMatch "\\.(ico|jpe?g|png|gif|swf)$"><br />Header set Cache-Control "max-age=2692000, public"<br /></FilesMatch><br /><FilesMatch "\\.(css)$"><br />Header set Cache-Control "max-age=2692000, public"<br /></FilesMatch><br /><FilesMatch "\\.(js)$"><br />Header set Cache-Control "max-age=216000, private"<br /></FilesMatch><br /><FilesMatch "\\.(x?html?|php)$"><br />Header set Cache-Control "max-age=600, private, must-revalidate"<br /></FilesMatch><br />Header unset ETag<br />Header unset Last-Modified<br /></IfModule><br /><br /><br />This is the exact same code I use on every property I manage and offers for me (and PageSpeed) the most satisfying results. One may argue on specific rules, that's why I said that it satisfies me, but it certainly satisfies PageSpeed.Userhttps://www.blogger.com/profile/11557173689529910046noreply@blogger.com