.kwpcf precache format - Flipnote-Collective/flipnote-studio-3d-docs GitHub Wiki
The kwpcf format is a type of resource cache format used by the Flipnote Studio 3D web client. These files can contain a number of embedded page resources (e.g. images or stylesheets) listed by their URL, or additional SSL certificate files which will be added to the cert trust chain.
They are used as a means of reducing requests to the server, and thus can be used to make pages load far quicker.
The web client parses the <head>
of a html document and loads any kwpcf files before moving on to parsing the rest of the page. If it comes across a reference to an external resource, such as an <img>
tag or a stylesheet link, it will check the page's KWPCF files for that external resource by searching for its URL. If it doesn't find a match in any of the kwpcfs, it will fetch the resource the usual way.
kwpcfs are linked using a meta tag within the head of the page:
<head>
<meta name="kwprecache" content="http(s)://url/path/filename.kwpcf">
</head>
kwpcf files don't have any file-specific headers, but are structured into seperate sections for each resource. All sections have an 8-byte header with a magic/identifier value, followed by the section size. The section magic indicates the resource type.
NOTE: unlike other formats, sections are not padded so that they will start on a multiple of 4 bytes. This means values can start on odd memory addresses and will make things inconvenient if using a low-level language.
Type | Content | Detail |
---|---|---|
char[4] |
magic | KPCF |
uint32 |
size | doesn't include size of header |
char[512] |
resource URL | utf-8, null-padded to 512 bytes |
byte[] |
resource data | size is equal to section size minus 512 |
Type | Content | Detail |
---|---|---|
char[4] |
magic | KDER |
uint32 |
size | doesn't include size of header |
byte[] |
cert data | DER format certificate |