001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.wicket.request.resource.caching;
018
019import org.apache.wicket.MetaDataKey;
020import org.apache.wicket.request.resource.AbstractResource;
021
022/**
023 * caching strategy for cacheable resources
024 * <p/>
025 * it can add and remove caching information to the filename and query 
026 * string parameters of the requested resource to control caches in the
027 * browser and on the internet. It also can set http response caching headers.
028 * 
029 * @author Peter Ertl
030 * 
031 * @since 1.5
032 */
033public interface IResourceCachingStrategy
034{
035
036        /**
037         * A key used to store the extracted resource's version in
038         * {@linkplain #undecorateUrl(ResourceUrl)} into the request cycle
039         */
040        MetaDataKey<String> URL_VERSION = new MetaDataKey<>()
041        {
042        };
043
044        /**
045         * add caching related information to filename + parameters
046         * 
047         * @param url
048         *            parameters to which caching information should be added and which will be used to
049         *            construct the url to the resource
050         * 
051         * @param resource
052         *            cacheable resource
053         */
054        void decorateUrl(ResourceUrl url, IStaticCacheableResource resource);
055
056        /**
057         * Removes caching related information from filename + parameters. In essenese this method
058         * undoes what 
059         * {@link #decorateUrl(ResourceUrl, IStaticCacheableResource)} 
060         * did.
061         * 
062         * @param url
063         *            parameters that were used to construct the url to the resource and from which
064         *            previously added caching information should be stripped
065         */
066        void undecorateUrl(ResourceUrl url);
067
068        /**
069         * decorate resource response
070         * 
071         * @param response
072         */
073        void decorateResponse(AbstractResource.ResourceResponse response, IStaticCacheableResource resource);
074
075        /**
076         * Clears any stateful information
077         */
078        void clearCache();
079
080}