Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

GREYThe locking was solved in 4.3, other improvements are pendingGREY

There are 4 main areas to study/develop in order to have a simplified and faster caching module:

  1. separate client caching from server-side caching
  2. remove byte arrays and use stream to write to e read from cache elements
  3. synchronize read / write operations at cache element level, not at global cache level
  4. add a global voter

Separate client caching from server-side caching

Split cache filter in two filters (cachable resources are the resources not bypassed):

  • Headers filter, with a manager (the simple implementation is an in-memory (concurrenthashmap) table) to
    • store response headers
    • apply max-age and Expires (or no-cache), or whatever else (for example ETags)
    • check request headers in order to send back to client SC_NOT_MODIFIED
  • Content filter, with a manager (the simple implementation is a filesystem based manager) to
    • cache resources by streaming response (multiplex streams) to an outputstream taken from cache element
    • check for SC_NOT_MODIFIED using cache element creation date
    • stream from cache using an inputstream

Memory consumption optimization

Optimize memory usage by removing the use of byte arrays both in writing to cache and reading from cache

Cache locking

Use the java.util.concurrent.locks.ReentrantReadWriteLock ReadLock and WriteLock to do per-element resource locking

Global cache voter


public class AllInOneCacheVoter extends AbstractBoolVoter

    private String allowedExtensions;

    private String deniedExtensions;

    private String allowedRequestContentTypes;

    private String deniedRequestContentTypes;

    private String allowedResponseContentTypes;

    private String deniedResponseContentTypes;

    private boolean allowRequestWithParameters = false;

    private boolean allowAdmin = false;

    private boolean allowAuthenticated = false;

    private boolean allowDocroot = true;

    private boolean allowDotResources = true;

    private boolean allowDotMagnolia = false;

    private VoterSet voters = new VoterSet();

    // called by Content2Bean
    public void init()
       if (StringUtils.isNotBlank(allowedExtensions) || StringUtils.isNotBlank(deniedExtensions))
            ExtensionVoter voter = new ExtensionVoter();
       ... create voters and add them to voters

     * {@inheritDoc}
    protected boolean boolVote(Object value)
        return == 0;

    ... getters and setters ...
  • No labels