Revision [5263]

This is an old revision of WikkaOptimization made by JavaWoman on 2005-01-27 09:10:36.

 

How to optimize Wikka?


Css and WikiEdit should be served with content-encoding = gzip.

To save bandwidth, we may use gzip content encoding with text files, like Css and Javascript. I exploited the file mime_types.txt distributed with Wikka but css files are served as application/x-ilinc-pointplus, 'coz css extension is registered with this content-type. I need advices.
elseif (preg_match('/\.css$/', $this->method))
{
    #header('Location: css/' . $this->method); We replace this with :
    $filename = "css/{$this->method}.gz";
    if (file_exists($filename))
    {
        $content_length = filesize($filename);
        $etag = md5($filename . filemtime($filename) . filesize($filename)); #If the file wasn't modified, we will get the same etag.
        $expiry = gmdate("D, j M Y G:i:s", time()+28512000); #expires after 11 months
        header("Etag: $etag");
        if (strstr($_SERVER['HTTP_IF_NONE_MATCH'], $etag))
        {
            header('HTTP/1.1 304 Not Modified');
            die();
        }
        header('Content-Encoding: gzip');
        header("Content-Length: $content_length");
        header("Expires: $expiry GMT");
        header("Cache-Control: public, must-revalidate");
        header("Content-Type: text/css");  #Very important, because php scripts will be served as text/html by default
        $data = implode('', file($filename));
        die ($data);
    }
    else
    {
        header('HTTP/1.1 404 Not Found');
        die();
    }
}


Wikka's ETag is meaningless

See the code below :
$etag =  md5($content);
header('ETag: '. $etag);

$content is the content of the page, including header (action header.php) and footer (action footer.php). But you see that in footer.php, the phrase 'Generated in x,xxxx seconds' is very rarely the same. Thus, a wiki page loaded at time (t) and reloaded at time (t+1) will have two different values for the header ETag.

I think the header and the footer should be excluded when calculating ETag. Ie, implement the method Run like this :
            print($this->Header());
   $content = $this->Method($this->method);
   echo $content;
   $GLOBALS['ETag'] = md5($content);
   print ($this->Footer());
        }
    }
}

and send the ETag header like this :
header("ETag: {$GLOBALS['ETag']}");


Another simple way is to use md5 of the date of latest change of the page instead of the content.

Question : How does a webserver handle the If-Match, If-None-Match and If-Range request lines? Because Wikka sets manually the header ETag, I think it has also to handle manually these type of request-line.

(Google:rfc2616 for Documentation about Etag ...)

3.11 Entity Tags
Entity tags are used for comparing two or more entities from the same
requested resource. HTTP/1.1 uses entity tags in the ETag (section
14.19), If-Match (Section 14.24), If-None-Match (Section 14.26), and
If-Range (Section 14.27) header fields. The definition of how they
are used and compared as cache validators is in Section 13.3.3. An
entity tag consists of an opaque quoted string, possibly prefixed by
a weakness indicator.

entity-tag = [ weak ] opaque-tag
weak = "W/"
opaque-tag = quoted-string

A "strong entity tag" MAY be shared by two entities of a resource
only if they are equivalent by octet equality.

A "weak entity tag," indicated by the "W/" prefix, MAY be shared by
two entities of a resource only if the entities are equivalent and
could be substituted for each other with no significant change in
semantics. A weak entity tag can only be used for weak comparison.

An entity tag MUST be unique across all versions of all entities
associated with a particular resource. A given entity tag value MAY
be used for entities obtained by requests on different URIs. The use
of the same entity tag value in conjunction with entities obtained by
requests on different URIs does not imply the equivalence of those
entities.

 

Category
CategoryDevelopment
There is one comment on this page. [Display comment]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki