Skip to content

Commit

Permalink
Return for expireCache and expireClints, switching to counting in sec…
Browse files Browse the repository at this point in the history
…onds

git-svn-id: http://geowebcache.org/svn/trunk@459 e7b91dd5-889a-44ae-8e97-0abfc27e49b2
  • Loading branch information
Arne Kepp committed Dec 8, 2008
1 parent f6c74f9 commit bcf0304
Showing 1 changed file with 21 additions and 26 deletions.
47 changes: 21 additions & 26 deletions geowebcache/src/main/java/org/geowebcache/layer/wms/WMSLayer.java
Expand Up @@ -77,17 +77,17 @@ public class WMSLayer extends TileLayer {
private String palette;

private String cachePrefix;

private int expireCache;

private int expireClients;

private String vendorParameters;

private transient int curWmsURL;

private transient boolean saveExpirationHeaders;

private transient long expireClients;

private transient long expireCache;

private transient Cache cache;

private transient CacheKey cacheKey;
Expand Down Expand Up @@ -293,7 +293,8 @@ private Tile getMetatilingReponse(Tile tile, boolean tryCache)
}

if (saveExpirationHeaders) {
saveExpirationInformation(tile.getExpiresHeader());
// Converting to seconds
saveExpirationInformation((int) (tile.getExpiresHeader() / 1000));
}

metaTile.setImageBytes(response);
Expand Down Expand Up @@ -361,7 +362,8 @@ private Tile getNonMetatilingReponse(Tile tile, boolean tryCache)
}

if (saveExpirationHeaders) {
saveExpirationInformation(tile.getExpiresHeader());
// Converting to seconds in the process
saveExpirationInformation((int) (tile.getExpiresHeader() / 1000));
}

/** ****************** Return lock and response ****** */
Expand Down Expand Up @@ -408,11 +410,10 @@ public void setExpirationHeader(HttpServletResponse response) {

// TODO move to TileResponse
if (expireClients > 0) {
int seconds = (int) (expireClients / 1000);
response.setHeader("Cache-Control", "max-age=" + seconds
response.setHeader("Cache-Control", "max-age=" + expireClients
+ ", must-revalidate");
response.setHeader("Expires", ServletUtils
.makeExpiresHeader(seconds));
.makeExpiresHeader(expireClients));
} else if (expireClients == GWCVars.CACHE_NEVER_EXPIRE) {
long oneYear = 3600 * 24 * 365;
response.setHeader("Cache-Control", "max-age=" + oneYear);
Expand Down Expand Up @@ -569,33 +570,27 @@ private void initParameters() throws GeoWebCacheException {
cache.setUp(cachePrefix);
}

protected void saveExpirationInformation(long backendExpire) {
protected void saveExpirationInformation(int backendExpire) {
this.saveExpirationHeaders = false;
try {
if (expireCache == GWCVars.CACHE_USE_WMS_BACKEND_VALUE) {
Long expire = backendExpire;
if (expire == null || expire == -1) {
expire = Long.valueOf(7200 * 1000);
if(backendExpire == -1) {
expireCache = 7200;
log.error("Layer profile wants MaxAge from backend,"
+ " but backend does not provide this. Setting to 7200 seconds.");
} else {
// Go from seconds to milliseconds
expire = expire * 1000;
expireCache = backendExpire;
}
log.error("Layer profile wants MaxAge from backend,"
+ " but backend does not provide this. Setting to 7200 seconds.");
expireCache = expire.longValue();
log.trace("Setting expireCache to: " + expireCache);
}
if (expireClients == GWCVars.CACHE_USE_WMS_BACKEND_VALUE) {
Long expire = backendExpire;
if (expire == null || expire == -1) {
expire = Long.valueOf(7200 * 1000);
if(backendExpire == -1) {
expireClients = 7200;
log.error("Layer profile wants MaxAge from backend,"
+ " but backend does not provide this. Setting to 7200 seconds.");
} else {
// Go from seconds to milliseconds
expire = expire * 1000;
expireClients = backendExpire;
}
log.error("Layer profile wants MaxAge from backend,"
+ " but backend does not provide this. Setting to 7200 seconds.");
expireClients = expire.longValue();
log.trace("Setting expireClients to: " + expireClients);
}
} catch (Exception e) {
Expand Down

0 comments on commit bcf0304

Please sign in to comment.