Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add ability to specify custom cache duration

Closes issue #5
  • Loading branch information...
commit 7166496569a5f3477052f68c52388067efed66ff 1 parent 9b3fa36
@Daniel15 authored
View
1  Source/Rejuicer/Rejuicer/Engine/OutputContent.cs
@@ -18,6 +18,7 @@ public OutputContent()
public byte[] ContentHash { get; set; }
public string ContentType { get; set; }
public bool AllowClientCaching { get; set; }
+ public TimeSpan? CacheFor { get; set; }
public DateTime LastModifiedDate { get; set; }
}
}
View
2  Source/Rejuicer/Rejuicer/Engine/RejuicerModule.cs
@@ -43,7 +43,7 @@ private static void context_BeginRequest(object sender, EventArgs e)
if (result.AllowClientCaching)
{
- response.Expires = 525600; // Browser cache expires after one year
+ response.Expires = (int)(result.CacheFor ?? TimeSpan.FromDays(365)).TotalMinutes;
response.CacheControl = "public";
// Any entity can cache this - be it the browser or a proxy server
}
View
6 Source/Rejuicer/Rejuicer/Fluent/CompactorConfigurer.cs
@@ -64,5 +64,11 @@ public ICompactorContextSelector ExceptWhenDebugging
{
get { _config.Context = Context.ExceptWhenDebugging; return this; }
}
+
+ public ICompactorConfigurer CacheFor(TimeSpan cacheTime)
+ {
+ _config.CacheFor = cacheTime;
+ return this;
+ }
}
}
View
1  Source/Rejuicer/Rejuicer/Fluent/ICompactorConfigurer.cs
@@ -13,6 +13,7 @@ public interface ICompactorConfigurer
ICompactorConfigurer File(string virtualPath, Mode mode);
IDirectoryFileMatchConfigurer FilesIn(string path);
IDirectoryFileMatchConfigurer FilesIn(string path, Mode mode);
+ ICompactorConfigurer CacheFor(TimeSpan cacheTime);
void Configure();
}
View
5 Source/Rejuicer/Rejuicer/Model/RejuicerConfigurationSource.cs
@@ -42,6 +42,8 @@ public RejuicerConfigurationSource(ResourceType resourceType, string requestedFi
public Mode Mode { get; set; }
+ public TimeSpan? CacheFor { get; set; }
+
public void AddRule(IContentSourceRule rule)
{
_lock.EnterWriteLock();
@@ -143,7 +145,8 @@ public OutputContent GetContent(ICacheProvider cacheProvider)
{
Content = minifiedContent,
ContentHash = minifiedContent.HashArray(),
- AllowClientCaching = ContainsPlaceHolder,
+ AllowClientCaching = ContainsPlaceHolder || CacheFor.HasValue,
+ CacheFor = CacheFor,
ContentType = minificationProvider.GetContentType(RequestFor),
LastModifiedDate = content.Max(x => x.LastModifiedDate)
};
Please sign in to comment.
Something went wrong with that request. Please try again.