Optimizer Secrets

    Since I am not doing this, I am only preparing the ground for their work, I am writing what is known to some, but to many interesting.

    1) Last-Modified and If-Modified-Since headers.

    For proper indexing by your site’s search engines, each page should produce a Last-Modified header and correctly process requests with the If-Modified-Since clause. If the page has not changed since the time specified in the request, the server should issue “HTTP / 1.1 304 Not Modified.”

    An example php code for the simplest case when the script contains all the data:

    header ("Last-Modified:". gmdate ("D, d MYH: i: s", filemtime ($ _ SERVER ['SCRIPT_FILENAME'])). "GMT");

    Insert at the top of each page.

    Added: In other cases, instead of “filemtime ($ _ SERVER ['SCRIPT_FILENAME'])”, the last date of the change in the data displayed on this page must be substituted.

    2) Gzip compression

    Significantly reduces page loading time.

    Php code, insert the first line:

    ob_start ('ob_gzhandler');

    3) Proper browser caching of images

    Pictures should be cached for at least a month. For an HTTP image request, a caption should be issued like "Cache-Control: max-age = 999999"
    To do this, insert

    ExpiresActive On
    ExpiresByType image / gif “access plus 3 month”
    ExpiresByType image / jpeg “access plus 3 month”

    in .htaccess at the root of the site.

    For those who do not have the module loaded, add

    LoadModule expires_module libexec / mod_expires.so
    AddModule mod_expires.c

    to the begining.

    4) Fix a problem with "Options + MultiViews"

    For those who use "Options + MultiViews" - problems with search engines are possible. With the default settings in Apache, he has problems with selecting a file (php scripts do not have a mime-type). Insert a cure for this problem.

    AddType text / html php

    in .htaccess at the root of the site.

    5) Mirrors

    If your site has a mirror, to avoid a possible ban in search engines, insert

    User-Agent: *
    Host: www.site.ru

    in robots.txt at the root of the site.

    6) Hosts www.site.ru and site.ru

    At the site.ru address, the header “HTTP / 1.1 301 Moved Permanently” should be issued. For example, there will be a correct calculation of the TIC.

    7) Add yours :-)

    Also popular now: