13.6 swap.state

A swap.state file is a journal of objects that have been added to, and removed from, a cache directory. Each cache_dir has its own swap.state file. When Squid starts up, it reads the swap.state files to rebuild its in-memory indexes of cached objects. These files are a relatively critical part of Squid's operation.

By default, each swap.state file is located in its corresponding cache directory. Thus, each state file automatically stays with each cache_dir. This is important if you ever decide to reorder your cache_dir lines or if you remove one or more from the list.

If you prefer to put them in a different location, you can use the cache_swap_log directive:

cache_swap_log /usr/local/squid/var/logs/swap.state

In this case, Squid creates a swap.state file for each directory by appending a numeric suffix. For example, if you have four cache directories, Squid creates the following:

/usr/local/squid/var/logs/swap.state.00

/usr/local/squid/var/logs/swap.state.01

/usr/local/squid/var/logs/swap.state.02

/usr/local/squid/var/logs/swap.state.03

In this situation, if you add, remove, or rearrange cache_dir lines, you may need to rename the swap.state files manually to keep everything consistent.

Technically, the swap.state format is storage scheme-dependent. However, all storage schemes use the same format in the current versions of Squid. The swap.state file uses a fixed-size (48-byte) binary format. Fields are written in host-byte order and are thus not necessarily portable between different operating systems. Table 13-3 describes the fields of a swap.state entry.

Table 13-3. swap.state entry fields

Name

Size, in bytes

Description

op

1

Operation on the entry: added (1) or deleted (2).

file number

4

Same as the fourth field of store.log, except it is stored in binary.

timestamp

4

A timestamp corresponding to the time when the response was generated or last validated. Taken from the Date header for responses that have one. Stored as the number of seconds since the Unix epoch.

lastref

4

A timestamp corresponding to the most recent access to the object.

expires

4

The object's expiration time, taken from an Expires header or Cache-Control max-age directive.

last-modified

4

The object's Last-Modified value.

swap file size

4

The amount of space the object occupies on disk. This includes HTTP headers and other Squid-specific meta-information.

refcount

2

The number of times this object has been requested.

flags

2

Various internal flags used by Squid.

key

16

The MD5 hash of the corresponding URI. Same as the key in store.log, except this one is stored in binary.



    Appendix A. Config File Reference
     
    ASPTreeView.com
     
    Evaluation has Б»КМёµМexpired.
    Info...