Class HTTPCache


  • @Deprecated
    public class HTTPCache
    extends java.lang.Object
    Deprecated.
    A "simple" HTTP cache. - Use a mix of parameters and hashcode + lenght with fixed (max) lenght? (Hashcodes of Strings are constant). - Store full filenames in .vary, instead of just extension, and use short filenames? (and only one .vary per dir).

    Version:
    $Id: HTTPCache.java#4 $
    Author:
    Harald Kuhr
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static java.lang.String FILE_EXT_HEADERS
      Deprecated.
      The file extension for header files (".headers")
      protected static java.lang.String FILE_EXT_VARY
      Deprecated.
      The file extension for varation-info files (".vary")
      protected static java.lang.String HEADER_CACHE_CONTROL
      Deprecated.
      The HTTP header "Cache-Control"
      protected static java.lang.String HEADER_CACHED_TIME
      Deprecated.
      HTTP extension header "X-Cached-At"
      protected static java.lang.String HEADER_CONTENT_TYPE
      Deprecated.
      The HTTP header "Content-Type"
      protected static java.lang.String HEADER_DATE
      Deprecated.
      The HTTP header "Date"
      protected static java.lang.String HEADER_ETAG
      Deprecated.
      The HTTP header "ETag"
      protected static java.lang.String HEADER_EXPIRES
      Deprecated.
      The HTTP header "Expires"
      protected static java.lang.String HEADER_IF_MODIFIED_SINCE
      Deprecated.
      The HTTP header "If-Modified-Since"
      protected static java.lang.String HEADER_IF_NONE_MATCH
      Deprecated.
      The HTTP header "If-None-Match"
      protected static java.lang.String HEADER_LAST_MODIFIED
      Deprecated.
      The HTTP header "Last-Modified"
      protected static java.lang.String HEADER_PRAGMA
      Deprecated.
      The HTTP header "Pragma"
      protected static java.lang.String HEADER_VARY
      Deprecated.
      The HTTP header "Vary"
      protected static java.lang.String HEADER_WARNING
      Deprecated.
      The HTTP header "Warning"
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        HTTPCache​(java.io.File pTempFolder, long pDefaultCacheExpiryTime, int pMaxMemCacheSize, int pMaxCachedEntites, boolean pDeleteCacheOnExit)
      Deprecated.
      Creates an HTTPCache.
      protected HTTPCache​(java.io.File pTempFolder, long pDefaultCacheExpiryTime, int pMaxMemCacheSize, int pMaxCachedEntites, boolean pDeleteCacheOnExit, java.util.logging.Logger pLogger)
      Deprecated.
       
        HTTPCache​(java.lang.String pName, javax.servlet.ServletContext pContext, int pDefaultCacheExpiryTime, int pMaxMemCacheSize, int pMaxCachedEntites, boolean pDeleteCacheOnExit)
    • Field Detail

      • HEADER_CACHE_CONTROL

        protected static final java.lang.String HEADER_CACHE_CONTROL
        Deprecated.
        The HTTP header "Cache-Control"
        See Also:
        Constant Field Values
      • HEADER_CONTENT_TYPE

        protected static final java.lang.String HEADER_CONTENT_TYPE
        Deprecated.
        The HTTP header "Content-Type"
        See Also:
        Constant Field Values
      • HEADER_DATE

        protected static final java.lang.String HEADER_DATE
        Deprecated.
        The HTTP header "Date"
        See Also:
        Constant Field Values
      • HEADER_ETAG

        protected static final java.lang.String HEADER_ETAG
        Deprecated.
        The HTTP header "ETag"
        See Also:
        Constant Field Values
      • HEADER_EXPIRES

        protected static final java.lang.String HEADER_EXPIRES
        Deprecated.
        The HTTP header "Expires"
        See Also:
        Constant Field Values
      • HEADER_IF_MODIFIED_SINCE

        protected static final java.lang.String HEADER_IF_MODIFIED_SINCE
        Deprecated.
        The HTTP header "If-Modified-Since"
        See Also:
        Constant Field Values
      • HEADER_IF_NONE_MATCH

        protected static final java.lang.String HEADER_IF_NONE_MATCH
        Deprecated.
        The HTTP header "If-None-Match"
        See Also:
        Constant Field Values
      • HEADER_LAST_MODIFIED

        protected static final java.lang.String HEADER_LAST_MODIFIED
        Deprecated.
        The HTTP header "Last-Modified"
        See Also:
        Constant Field Values
      • HEADER_PRAGMA

        protected static final java.lang.String HEADER_PRAGMA
        Deprecated.
        The HTTP header "Pragma"
        See Also:
        Constant Field Values
      • HEADER_VARY

        protected static final java.lang.String HEADER_VARY
        Deprecated.
        The HTTP header "Vary"
        See Also:
        Constant Field Values
      • HEADER_WARNING

        protected static final java.lang.String HEADER_WARNING
        Deprecated.
        The HTTP header "Warning"
        See Also:
        Constant Field Values
      • HEADER_CACHED_TIME

        protected static final java.lang.String HEADER_CACHED_TIME
        Deprecated.
        HTTP extension header "X-Cached-At"
        See Also:
        Constant Field Values
      • FILE_EXT_HEADERS

        protected static final java.lang.String FILE_EXT_HEADERS
        Deprecated.
        The file extension for header files (".headers")
        See Also:
        Constant Field Values
      • FILE_EXT_VARY

        protected static final java.lang.String FILE_EXT_VARY
        Deprecated.
        The file extension for varation-info files (".vary")
        See Also:
        Constant Field Values
    • Constructor Detail

      • HTTPCache

        protected HTTPCache​(java.io.File pTempFolder,
                            long pDefaultCacheExpiryTime,
                            int pMaxMemCacheSize,
                            int pMaxCachedEntites,
                            boolean pDeleteCacheOnExit,
                            java.util.logging.Logger pLogger)
        Deprecated.
      • HTTPCache

        public HTTPCache​(java.io.File pTempFolder,
                         long pDefaultCacheExpiryTime,
                         int pMaxMemCacheSize,
                         int pMaxCachedEntites,
                         boolean pDeleteCacheOnExit)
        Deprecated.
        Creates an HTTPCache.
        Parameters:
        pTempFolder - the temp folder for this cache.
        pDefaultCacheExpiryTime - Default expiry time for cached entities, >= 0
        pMaxMemCacheSize - Maximum size of in-memory cache for content in bytes, >= 0 (0 means no in-memory cache)
        pMaxCachedEntites - Maximum number of entities in cache
        pDeleteCacheOnExit - specifies wether the file cache should be deleted when the application or VM shuts down
        Throws:
        java.lang.IllegalArgumentException - if pName or pContext is null or if any of pDefaultCacheExpiryTime, pMaxMemCacheSize or pMaxCachedEntites are negative, or if the directory as given in the context attribute "javax.servlet.context.tempdir" does not exist, and cannot be created.
      • HTTPCache

        @Deprecated
        public HTTPCache​(java.lang.String pName,
                         javax.servlet.ServletContext pContext,
                         int pDefaultCacheExpiryTime,
                         int pMaxMemCacheSize,
                         int pMaxCachedEntites,
                         boolean pDeleteCacheOnExit)
        Creates an HTTPCache.
        Parameters:
        pName - Name of this cache (should be unique per application). Used for temp folder
        pContext - Servlet context for the application.
        pDefaultCacheExpiryTime - Default expiry time for cached entities, >= 0
        pMaxMemCacheSize - Maximum size of in-memory cache for content in bytes, >= 0 (0 means no in-memory cache)
        pMaxCachedEntites - Maximum number of entities in cache
        pDeleteCacheOnExit - specifies wether the file cache should be deleted when the application or VM shuts down
        Throws:
        java.lang.IllegalArgumentException - if pName or pContext is null or if any of pDefaultCacheExpiryTime, pMaxMemCacheSize or pMaxCachedEntites are negative, or if the directory as given in the context attribute "javax.servlet.context.tempdir" does not exist, and cannot be created.
    • Method Detail

      • toString

        public java.lang.String toString()
        Deprecated.
        Overrides:
        toString in class java.lang.Object
      • doCached

        public void doCached​(CacheRequest pRequest,
                             CacheResponse pResponse,
                             ResponseResolver pResolver)
                      throws java.io.IOException,
                             CacheException
        Deprecated.
        Looks up the CachedEntity for the given request.
        Parameters:
        pRequest - the request
        pResponse - the response
        pResolver - the resolver
        Throws:
        java.io.IOException - if an I/O error occurs
        CacheException - if the cached entity can't be resolved for some reason
      • invalidate

        protected void invalidate​(CacheRequest pRequest)
        Deprecated.
      • getRealFile

        protected java.io.File getRealFile​(CacheRequest pRequest)
        Deprecated.
        Allows a server-side cache mechanism to peek at the real file. Default implementation return null.
        Parameters:
        pRequest - the request
        Returns:
        null, always