Dictionary Generation

39 views
Skip to first unread message

Oliver Mattos

unread,
Apr 14, 2009, 7:47:46 AM4/14/09
to SDCH
How are web servers expected to "generate" the dictionaries? Would it
be typical for an SDCH enabled server to generate a dictionary on the
fly based on common things in responses over say a 24 hour period and
then make the dictionary available during the next day?

If this is the case, are there plugins available for apache, IIS or
squid etc. to create, host, and advertise these dictionaries?

Alternatively, is the dictionary generated "by hand" by authors by
checking manually for common pieces of HTML in a page and generating a
dictionary. If this is the case, are there any pieces of software to
allow generation/viewing/editing the dictionary?

Ren

unread,
Apr 22, 2009, 6:20:04 AM4/22/09
to SDCH
I've toyed with the idea that can build a dictionary based on HTML
templates.
Using PHP templates, can get PHP to compile them for SDCH, and put any
static HTML into the dictionary.
So a PHP template something like...

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php $text
('lang'); ?>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title><?php $text('title'); ?></title>

<style type="text/css">
body { font-family: "Bitstream Vera Sans", sans-serif; font-size:
1.2em; }
table { border-collapse: collapse; }
th { background: #ddd; }
th, td { border: 1px solid #bbb; padding: 0 0.5em; }
</style>
</head>
<body>
<h1><?php $text('title'); ?></h1>

<h2><?php $dateTime($_SERVER['REQUEST_TIME']); ?></h2>

<table>
<thead>
<tr><th></th><th><?php $_('Name'); ?></th><th><?php $_('Price'); ?
></th><th><?php $_('Percent');?></tr>
</thead>
<tbody>
<?php foreach($data['rows'] as $i => $row) { ?>
<tr class="<?php if ($i & 1) { ?>odd<?php } else {?>even<?php }?
>">
<td><?php $ordinal($i + 1); ?></td>
<td><?php $escape($row['name']); ?></td>
<td><?php $currency($row['price']); ?></td>
<td><?php $percent($row['percent']); ?></td>
</tr>
<?php } ?>
</tbody>
</table>

<p>
<?php if ($data['previous']) { ?>
<a href=""><?php $_('prevn', $data['pageSize']); ?></a>
<?php }
if ($data['next']) { ?>
<a href=""><?php $_('nextn', $data['pageSize']); ?></a>
<?php } ?>
</p>
<p>
<a href="index.php">en</a>
<a href="index.php?lang=fr_FR&amp;tz=Europe/Paris">fr_FR</a>
<a href="index.php?lang=fr_CA&amp;tz=America/Blanc-Sablon">fr_CA</
a>
</p>
</body>
</html>

Gets compiled down to...

<?php /* SDCH compiled version of sdch\templates\template.php */
$encoder->copy(0, 53);$text('lang'); $encoder->copy(53, 91);$text
('title'); $encoder->copy(144, 12);$encoder->copy(156, 260);$text
('title'); $encoder->copy(416, 13);$dateTime($_SERVER
['REQUEST_TIME']); $encoder->copy(429, 49);$_('Name'); $encoder->copy
(478, 9);$_('Price'); $encoder->copy(487, 9);$_('Percent');$encoder-
>copy(496, 32);foreach($data['rows'] as $i => $row) { $encoder->copy
(528, 15);if ($i & 1) { ?>odd<?php } else {$encoder->copy(543, 4);}
$encoder->copy(547, 12);$ordinal($i + 1); $encoder->copy(559, 15);
$escape($row['name']); $encoder->copy(574, 15);$currency($row
['price']); $encoder->copy(589, 15);$percent($row['percent']);
$encoder->copy(604, 19);} $encoder->copy(623, 33);if ($data
['previous']) { $encoder->copy(656, 15);$_('prevn', $data
['pageSize']); $encoder->copy(671, 8);}
if ($data['next']) { $encoder->copy(679, 15);$_('nextn', $data
['pageSize']); $encoder->copy(694, 8);} $encoder->copy(702, 202);

So if the UserAgent supports SDCH and has the required dictionary, can
execute the SDCH version of the template, if not use the regular PHP.



Lincoln

unread,
Apr 22, 2009, 10:47:01 AM4/22/09
to SDCH
On Apr 14, 4:47 am, Oliver Mattos <omat...@gmail.com> wrote:
> [...] are there plugins available for apache, IIS or
> squid etc. to create, host, and advertise these dictionaries?

For the Apache case, someone created a placeholder project named "mod-
sdch" in September 2008, described as "Apache implementation of shared
dictionary comrpession over http", but there have not been any updates
on it since. You might wish to contact the project owner to ask about
it.
http://code.google.com/p/mod-sdch/
Reply all
Reply to author
Forward
0 new messages