Categorygithub.com/schorlet/simplecache
repositorypackage
2.0.0+incompatible
Repository: https://github.com/schorlet/simplecache.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

simplecache GoDoc

The simplecache package provides support for reading Chromium simple cache v6 or v7.

Learn more: http://www.chromium.org/developers/design-documents/network-stack/disk-cache/very-simple-backend

See the example_test.go for an example of how to read an image from cache in testdata.

This project also includes a tool to read the cache from command line, read this README.

Short cache format

The simple cache contains different files:

FilenameDescription
indexFake index file
#####_0Data stream file
#####_1Data stream file
#####_sData stream file
index-dir/the-real-indexThe real index file

Fake index file format (index)

offsetsizevaluedescription
080x656e74657220796fMagic
847Version
1280x0Padding

Real index file format (the-real-index)

Overview:

  • File header
  • Last write reason (starting v7)
  • Index table
  • Last modified

File header

The index file header (struct indexHeader) is 36 bytes in size and consists of:

offsetsizevaluedescription
04Payload size
44Payload CRC32
880x656e74657220796fMagic
1647Version
208Number of entries
288Cache size

Index table

The index table is an array of entries. An entry (struct indexEntry) is 24 bytes in size and consists of:

offsetsizevaluedescription
08Hash
88Last used
168Size

Data stream file format (#####_0)

Overview:

  • File header
  • URL
  • Data stream (stream 1)
  • Stream EOF
  • HTTP headers (stream 0)
  • (optionally) the SHA256 of the URL
  • Stream EOF

File header

The index file header (struct entryHeader) is 20 bytes in size and consists of:

offsetsizevaluedescription
080xfcfb6d1ba7725c30Magic
845Version
124URL length
164URL MD5

Stream EOF

The separator (struct entryEOF) contains information about the stream above. It is 20 bytes in size and consists of:

offsetsizevaluedescription
080xf4fa6f45970d41d8Magic
84Flag
124stream CRC32
164stream size
Flag
valuedescription
0
1the stream has CRC32
2the URL has SHA256
31 + 2

Data stream file format (#####_1)

Overview:

  • File header
  • URL
  • Data stream (stream 2)
  • Stream EOF

Data stream file format (#####_s)

Overview:

  • File header
  • many of the following:
    • Range header
    • Range data stream

File header

The index file header (struct entryHeader) is 20 bytes in size and consists of:

offsetsizevaluedescription
080xfcfb6d1ba7725c30Magic
847Version
124URL length
164URL MD5

Range header

The range header (struct sparseRangeHeader) contains information about the following range stream. It is 28 bytes in size and consists of:

offsetsizevaluedescription
080xeb97bf016553676bMagic
88stream offset
168stream size
244stream CRC32