implementing Google Page Speed recommendations
When analyzing my various websites pages with Google Page Speed, I always have the fol开发者_如何学Golowing recommendations:
- leverage browser caching
- serve static content from a cookie-less domain
I have no idea on how to eliminate or implement these messages. Can this be done:
- through .htaccess
- through php code
- Apache configuration
How can this be done?
The Page Speed project page has a pretty detailed information about the recommendations including Leverage browser caching and Serve static content from a cookieless domain. Read these first and try to understand the problems and proposed solutions.
After that you can implement these recommendations. As you’re using an Apache web server, read Apache’s Caching Guide and the documentation to mod_expires, Apache’s main module for time based HTTP caching. And as for the cookie-less domain, read Apache’s virtual host documentation. With that you can set up a virtual host for your cookieless domain. Then you just need to make sure that your cookies are not valid for that domain (see Domain parameter).
For "serve static content from a cookie-less domain" you can create a subdomain in which you add a .htaccess file containing:
Header unset Cookie
Header unset Set-Cookie
精彩评论