diff --git a/samples/ResponseCachingSample/Startup.cs b/samples/ResponseCachingSample/Startup.cs
index 376443ef0b..cd135b8451 100644
--- a/samples/ResponseCachingSample/Startup.cs
+++ b/samples/ResponseCachingSample/Startup.cs
@@ -15,12 +15,12 @@ namespace ResponseCachingSample
{
public void ConfigureServices(IServiceCollection services)
{
- services.AddMemoryResponseCacheStore();
+ services.AddResponseCaching();
}
public void Configure(IApplicationBuilder app)
{
- app.UseResponseCache();
+ app.UseResponseCaching();
app.Run(async (context) =>
{
context.Response.GetTypedHeaders().CacheControl = new CacheControlHeaderValue()
diff --git a/src/Microsoft.AspNetCore.ResponseCaching.Abstractions/IResponseCacheFeature.cs b/src/Microsoft.AspNetCore.ResponseCaching.Abstractions/IResponseCachingFeature.cs
similarity index 79%
rename from src/Microsoft.AspNetCore.ResponseCaching.Abstractions/IResponseCacheFeature.cs
rename to src/Microsoft.AspNetCore.ResponseCaching.Abstractions/IResponseCachingFeature.cs
index 2306c410f8..c68c4c8c5c 100644
--- a/src/Microsoft.AspNetCore.ResponseCaching.Abstractions/IResponseCacheFeature.cs
+++ b/src/Microsoft.AspNetCore.ResponseCaching.Abstractions/IResponseCachingFeature.cs
@@ -1,18 +1,16 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-using Microsoft.Extensions.Primitives;
-
namespace Microsoft.AspNetCore.ResponseCaching
{
///
/// A feature for configuring additional response cache options on the HTTP response.
///
- public interface IResponseCacheFeature
+ public interface IResponseCachingFeature
{
///
/// Gets or sets the query keys used by the response cache middleware for calculating secondary vary keys.
///
- StringValues VaryByQueryKeys { get; set; }
+ string[] VaryByQueryKeys { get; set; }
}
}
diff --git a/src/Microsoft.AspNetCore.ResponseCaching/Internal/Interfaces/IResponseCacheStore.cs b/src/Microsoft.AspNetCore.ResponseCaching/Internal/Interfaces/IResponseCache.cs
similarity index 91%
rename from src/Microsoft.AspNetCore.ResponseCaching/Internal/Interfaces/IResponseCacheStore.cs
rename to src/Microsoft.AspNetCore.ResponseCaching/Internal/Interfaces/IResponseCache.cs
index 2deaa41708..cd3b9da23f 100644
--- a/src/Microsoft.AspNetCore.ResponseCaching/Internal/Interfaces/IResponseCacheStore.cs
+++ b/src/Microsoft.AspNetCore.ResponseCaching/Internal/Interfaces/IResponseCache.cs
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Microsoft.AspNetCore.ResponseCaching.Internal
{
- public interface IResponseCacheStore
+ public interface IResponseCache
{
Task GetAsync(string key);
Task SetAsync(string key, IResponseCacheEntry entry, TimeSpan validFor);
diff --git a/src/Microsoft.AspNetCore.ResponseCaching/Internal/Interfaces/IResponseCacheKeyProvider.cs b/src/Microsoft.AspNetCore.ResponseCaching/Internal/Interfaces/IResponseCachingKeyProvider.cs
similarity index 61%
rename from src/Microsoft.AspNetCore.ResponseCaching/Internal/Interfaces/IResponseCacheKeyProvider.cs
rename to src/Microsoft.AspNetCore.ResponseCaching/Internal/Interfaces/IResponseCachingKeyProvider.cs
index eb9d626824..ac6a20f005 100644
--- a/src/Microsoft.AspNetCore.ResponseCaching/Internal/Interfaces/IResponseCacheKeyProvider.cs
+++ b/src/Microsoft.AspNetCore.ResponseCaching/Internal/Interfaces/IResponseCachingKeyProvider.cs
@@ -5,27 +5,27 @@ using System.Collections.Generic;
namespace Microsoft.AspNetCore.ResponseCaching.Internal
{
- public interface IResponseCacheKeyProvider
+ public interface IResponseCachingKeyProvider
{
///
/// Create a base key for a response cache entry.
///
- /// The .
+ /// The .
/// The created base key.
- string CreateBaseKey(ResponseCacheContext context);
+ string CreateBaseKey(ResponseCachingContext context);
///
/// Create a vary key for storing cached responses.
///
- /// The .
+ /// The .
/// The created vary key.
- string CreateStorageVaryByKey(ResponseCacheContext context);
+ string CreateStorageVaryByKey(ResponseCachingContext context);
///
/// Create one or more vary keys for looking up cached responses.
///
- /// The .
+ /// The .
/// An ordered containing the vary keys to try when looking up items.
- IEnumerable CreateLookupVaryByKeys(ResponseCacheContext context);
+ IEnumerable CreateLookupVaryByKeys(ResponseCachingContext context);
}
}
diff --git a/src/Microsoft.AspNetCore.ResponseCaching/Internal/Interfaces/IResponseCachePolicyProvider.cs b/src/Microsoft.AspNetCore.ResponseCaching/Internal/Interfaces/IResponseCachingPolicyProvider.cs
similarity index 66%
rename from src/Microsoft.AspNetCore.ResponseCaching/Internal/Interfaces/IResponseCachePolicyProvider.cs
rename to src/Microsoft.AspNetCore.ResponseCaching/Internal/Interfaces/IResponseCachingPolicyProvider.cs
index 0560212018..77b3f28379 100644
--- a/src/Microsoft.AspNetCore.ResponseCaching/Internal/Interfaces/IResponseCachePolicyProvider.cs
+++ b/src/Microsoft.AspNetCore.ResponseCaching/Internal/Interfaces/IResponseCachingPolicyProvider.cs
@@ -3,27 +3,27 @@
namespace Microsoft.AspNetCore.ResponseCaching.Internal
{
- public interface IResponseCachePolicyProvider
+ public interface IResponseCachingPolicyProvider
{
///
/// Determine wehther the response cache middleware should be executed for the incoming HTTP request.
///
- /// The .
+ /// The .
/// true if the request is cacheable; otherwise false.
- bool IsRequestCacheable(ResponseCacheContext context);
+ bool IsRequestCacheable(ResponseCachingContext context);
///
/// Determine whether the response received by the middleware be cached for future requests.
///
- /// The .
+ /// The .
/// true if the response is cacheable; otherwise false.
- bool IsResponseCacheable(ResponseCacheContext context);
+ bool IsResponseCacheable(ResponseCachingContext context);
///
/// Determine whether the response retrieved from the response cache is fresh and be served.
///
- /// The .
+ /// The .
/// true if the cached entry is fresh; otherwise false.
- bool IsCachedEntryFresh(ResponseCacheContext context);
+ bool IsCachedEntryFresh(ResponseCachingContext context);
}
}
diff --git a/src/Microsoft.AspNetCore.ResponseCaching/Internal/MemoryResponseCacheStore.cs b/src/Microsoft.AspNetCore.ResponseCaching/Internal/MemoryResponseCache.cs
similarity index 95%
rename from src/Microsoft.AspNetCore.ResponseCaching/Internal/MemoryResponseCacheStore.cs
rename to src/Microsoft.AspNetCore.ResponseCaching/Internal/MemoryResponseCache.cs
index 02191c9603..4a855e2d24 100644
--- a/src/Microsoft.AspNetCore.ResponseCaching/Internal/MemoryResponseCacheStore.cs
+++ b/src/Microsoft.AspNetCore.ResponseCaching/Internal/MemoryResponseCache.cs
@@ -7,11 +7,11 @@ using Microsoft.Extensions.Caching.Memory;
namespace Microsoft.AspNetCore.ResponseCaching.Internal
{
- public class MemoryResponseCacheStore : IResponseCacheStore
+ public class MemoryResponseCache : IResponseCache
{
private readonly IMemoryCache _cache;
- public MemoryResponseCacheStore(IMemoryCache cache)
+ public MemoryResponseCache(IMemoryCache cache)
{
if (cache == null)
{
diff --git a/src/Microsoft.AspNetCore.ResponseCaching/Internal/ResponseCacheContext.cs b/src/Microsoft.AspNetCore.ResponseCaching/Internal/ResponseCachingContext.cs
similarity index 95%
rename from src/Microsoft.AspNetCore.ResponseCaching/Internal/ResponseCacheContext.cs
rename to src/Microsoft.AspNetCore.ResponseCaching/Internal/ResponseCachingContext.cs
index 5d0f4cc17c..4fc7292894 100644
--- a/src/Microsoft.AspNetCore.ResponseCaching/Internal/ResponseCacheContext.cs
+++ b/src/Microsoft.AspNetCore.ResponseCaching/Internal/ResponseCachingContext.cs
@@ -11,7 +11,7 @@ using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNetCore.ResponseCaching.Internal
{
- public class ResponseCacheContext
+ public class ResponseCachingContext
{
private static readonly CacheControlHeaderValue EmptyCacheControl = new CacheControlHeaderValue();
@@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Internal
private DateTimeOffset? _responseExpires;
private bool _parsedResponseExpires;
- internal ResponseCacheContext(HttpContext httpContext, ILogger logger)
+ internal ResponseCachingContext(HttpContext httpContext, ILogger logger)
{
HttpContext = httpContext;
Logger = logger;
@@ -54,7 +54,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Internal
internal Stream OriginalResponseStream { get; set; }
- internal ResponseCacheStream ResponseCacheStream { get; set; }
+ internal ResponseCachingStream ResponseCachingStream { get; set; }
internal IHttpSendFileFeature OriginalSendFileFeature { get; set; }
diff --git a/src/Microsoft.AspNetCore.ResponseCaching/Internal/ResponseCacheKeyProvider.cs b/src/Microsoft.AspNetCore.ResponseCaching/Internal/ResponseCachingKeyProvider.cs
similarity index 90%
rename from src/Microsoft.AspNetCore.ResponseCaching/Internal/ResponseCacheKeyProvider.cs
rename to src/Microsoft.AspNetCore.ResponseCaching/Internal/ResponseCachingKeyProvider.cs
index ed1e449ce0..334022647a 100644
--- a/src/Microsoft.AspNetCore.ResponseCaching/Internal/ResponseCacheKeyProvider.cs
+++ b/src/Microsoft.AspNetCore.ResponseCaching/Internal/ResponseCachingKeyProvider.cs
@@ -5,23 +5,21 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
-using Microsoft.AspNetCore.Builder;
-using Microsoft.AspNetCore.ResponseCaching.Internal;
using Microsoft.Extensions.ObjectPool;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Primitives;
namespace Microsoft.AspNetCore.ResponseCaching.Internal
{
- public class ResponseCacheKeyProvider : IResponseCacheKeyProvider
+ public class ResponseCachingKeyProvider : IResponseCachingKeyProvider
{
// Use the record separator for delimiting components of the cache key to avoid possible collisions
private static readonly char KeyDelimiter = '\x1e';
private readonly ObjectPool _builderPool;
- private readonly ResponseCacheOptions _options;
+ private readonly ResponseCachingOptions _options;
- public ResponseCacheKeyProvider(ObjectPoolProvider poolProvider, IOptions options)
+ public ResponseCachingKeyProvider(ObjectPoolProvider poolProvider, IOptions options)
{
if (poolProvider == null)
{
@@ -36,13 +34,13 @@ namespace Microsoft.AspNetCore.ResponseCaching.Internal
_options = options.Value;
}
- public IEnumerable CreateLookupVaryByKeys(ResponseCacheContext context)
+ public IEnumerable CreateLookupVaryByKeys(ResponseCachingContext context)
{
return new string[] { CreateStorageVaryByKey(context) };
}
// GET/PATH
- public string CreateBaseKey(ResponseCacheContext context)
+ public string CreateBaseKey(ResponseCachingContext context)
{
if (context == null)
{
@@ -76,7 +74,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Internal
}
// BaseKeyHHeaderName=HeaderValueQQueryName=QueryValue
- public string CreateStorageVaryByKey(ResponseCacheContext context)
+ public string CreateStorageVaryByKey(ResponseCachingContext context)
{
if (context == null)
{
@@ -86,7 +84,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Internal
var varyByRules = context.CachedVaryByRules;
if (varyByRules == null)
{
- throw new InvalidOperationException($"{nameof(CachedVaryByRules)} must not be null on the {nameof(ResponseCacheContext)}");
+ throw new InvalidOperationException($"{nameof(CachedVaryByRules)} must not be null on the {nameof(ResponseCachingContext)}");
}
if ((StringValues.IsNullOrEmpty(varyByRules.Headers) && StringValues.IsNullOrEmpty(varyByRules.QueryKeys)))
diff --git a/src/Microsoft.AspNetCore.ResponseCaching/Internal/ResponseCachePolicyProvider.cs b/src/Microsoft.AspNetCore.ResponseCaching/Internal/ResponseCachingPolicyProvider.cs
similarity index 96%
rename from src/Microsoft.AspNetCore.ResponseCaching/Internal/ResponseCachePolicyProvider.cs
rename to src/Microsoft.AspNetCore.ResponseCaching/Internal/ResponseCachingPolicyProvider.cs
index cc7f174a07..0072546ef7 100644
--- a/src/Microsoft.AspNetCore.ResponseCaching/Internal/ResponseCachePolicyProvider.cs
+++ b/src/Microsoft.AspNetCore.ResponseCaching/Internal/ResponseCachingPolicyProvider.cs
@@ -8,11 +8,11 @@ using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNetCore.ResponseCaching.Internal
{
- public class ResponseCachePolicyProvider : IResponseCachePolicyProvider
+ public class ResponseCachingPolicyProvider : IResponseCachingPolicyProvider
{
private static readonly CacheControlHeaderValue EmptyCacheControl = new CacheControlHeaderValue();
- public virtual bool IsRequestCacheable(ResponseCacheContext context)
+ public virtual bool IsRequestCacheable(ResponseCachingContext context)
{
// Verify the method
var request = context.HttpContext.Request;
@@ -55,7 +55,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Internal
return true;
}
- public virtual bool IsResponseCacheable(ResponseCacheContext context)
+ public virtual bool IsResponseCacheable(ResponseCachingContext context)
{
// Only cache pages explicitly marked with public
if (!context.ResponseCacheControlHeaderValue.Public)
@@ -155,7 +155,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Internal
return true;
}
- public virtual bool IsCachedEntryFresh(ResponseCacheContext context)
+ public virtual bool IsCachedEntryFresh(ResponseCachingContext context)
{
var age = context.CachedEntryAge.Value;
var cachedControlHeaders = context.CachedResponseHeaders.CacheControl ?? EmptyCacheControl;
diff --git a/src/Microsoft.AspNetCore.ResponseCaching/Internal/SendFileFeatureWrapper.cs b/src/Microsoft.AspNetCore.ResponseCaching/Internal/SendFileFeatureWrapper.cs
index 5d6264228e..2716e4cd37 100644
--- a/src/Microsoft.AspNetCore.ResponseCaching/Internal/SendFileFeatureWrapper.cs
+++ b/src/Microsoft.AspNetCore.ResponseCaching/Internal/SendFileFeatureWrapper.cs
@@ -10,18 +10,18 @@ namespace Microsoft.AspNetCore.ResponseCaching.Internal
internal class SendFileFeatureWrapper : IHttpSendFileFeature
{
private readonly IHttpSendFileFeature _originalSendFileFeature;
- private readonly ResponseCacheStream _responseCacheStream;
+ private readonly ResponseCachingStream _responseCachingStream;
- public SendFileFeatureWrapper(IHttpSendFileFeature originalSendFileFeature, ResponseCacheStream responseCacheStream)
+ public SendFileFeatureWrapper(IHttpSendFileFeature originalSendFileFeature, ResponseCachingStream responseCachingStream)
{
_originalSendFileFeature = originalSendFileFeature;
- _responseCacheStream = responseCacheStream;
+ _responseCachingStream = responseCachingStream;
}
// Flush and disable the buffer if anyone tries to call the SendFile feature.
public Task SendFileAsync(string path, long offset, long? length, CancellationToken cancellation)
{
- _responseCacheStream.DisableBuffering();
+ _responseCachingStream.DisableBuffering();
return _originalSendFileFeature.SendFileAsync(path, offset, length, cancellation);
}
}
diff --git a/src/Microsoft.AspNetCore.ResponseCaching/ResponseCacheExtensions.cs b/src/Microsoft.AspNetCore.ResponseCaching/ResponseCacheExtensions.cs
deleted file mode 100644
index 8b96c3e8d8..0000000000
--- a/src/Microsoft.AspNetCore.ResponseCaching/ResponseCacheExtensions.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using Microsoft.AspNetCore.ResponseCaching;
-using Microsoft.Extensions.Options;
-
-namespace Microsoft.AspNetCore.Builder
-{
- public static class ResponseCacheExtensions
- {
- public static IApplicationBuilder UseResponseCache(this IApplicationBuilder app)
- {
- if (app == null)
- {
- throw new ArgumentNullException(nameof(app));
- }
-
- return app.UseMiddleware();
- }
-
- public static IApplicationBuilder UseResponseCache(this IApplicationBuilder app, ResponseCacheOptions options)
- {
- if (app == null)
- {
- throw new ArgumentNullException(nameof(app));
- }
- if (options == null)
- {
- throw new ArgumentNullException(nameof(options));
- }
-
- return app.UseMiddleware(Options.Create(options));
- }
- }
-}
diff --git a/src/Microsoft.AspNetCore.ResponseCaching/ResponseCacheServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.ResponseCaching/ResponseCacheServiceCollectionExtensions.cs
deleted file mode 100644
index b8020b56f9..0000000000
--- a/src/Microsoft.AspNetCore.ResponseCaching/ResponseCacheServiceCollectionExtensions.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using Microsoft.AspNetCore.ResponseCaching;
-using Microsoft.AspNetCore.ResponseCaching.Internal;
-using Microsoft.Extensions.DependencyInjection.Extensions;
-
-namespace Microsoft.Extensions.DependencyInjection
-{
- public static class ResponseCacheServiceCollectionExtensions
- {
- public static IServiceCollection AddMemoryResponseCacheStore(this IServiceCollection services)
- {
- if (services == null)
- {
- throw new ArgumentNullException(nameof(services));
- }
-
- services.AddMemoryCache();
- services.TryAdd(ServiceDescriptor.Singleton());
- services.TryAdd(ServiceDescriptor.Singleton());
- services.TryAdd(ServiceDescriptor.Singleton());
-
- return services;
- }
- }
-}
diff --git a/src/Microsoft.AspNetCore.ResponseCaching/ResponseCachingExtensions.cs b/src/Microsoft.AspNetCore.ResponseCaching/ResponseCachingExtensions.cs
new file mode 100644
index 0000000000..76b81dbccb
--- /dev/null
+++ b/src/Microsoft.AspNetCore.ResponseCaching/ResponseCachingExtensions.cs
@@ -0,0 +1,22 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using Microsoft.AspNetCore.ResponseCaching;
+using Microsoft.Extensions.Options;
+
+namespace Microsoft.AspNetCore.Builder
+{
+ public static class ResponseCachingExtensions
+ {
+ public static IApplicationBuilder UseResponseCaching(this IApplicationBuilder app)
+ {
+ if (app == null)
+ {
+ throw new ArgumentNullException(nameof(app));
+ }
+
+ return app.UseMiddleware();
+ }
+ }
+}
diff --git a/src/Microsoft.AspNetCore.ResponseCaching/ResponseCacheFeature.cs b/src/Microsoft.AspNetCore.ResponseCaching/ResponseCachingFeature.cs
similarity index 73%
rename from src/Microsoft.AspNetCore.ResponseCaching/ResponseCacheFeature.cs
rename to src/Microsoft.AspNetCore.ResponseCaching/ResponseCachingFeature.cs
index 4c0b129ff4..14232b97de 100644
--- a/src/Microsoft.AspNetCore.ResponseCaching/ResponseCacheFeature.cs
+++ b/src/Microsoft.AspNetCore.ResponseCaching/ResponseCachingFeature.cs
@@ -2,15 +2,14 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
-using Microsoft.Extensions.Primitives;
namespace Microsoft.AspNetCore.ResponseCaching
{
- public class ResponseCacheFeature : IResponseCacheFeature
+ public class ResponseCachingFeature : IResponseCachingFeature
{
- private StringValues _varyByQueryKeys;
+ private string[] _varyByQueryKeys;
- public StringValues VaryByQueryKeys
+ public string[] VaryByQueryKeys
{
get
{
@@ -18,9 +17,9 @@ namespace Microsoft.AspNetCore.ResponseCaching
}
set
{
- if (value.Count > 1)
+ if (value?.Length > 1)
{
- for (var i = 0; i < value.Count; i++)
+ for (var i = 0; i < value.Length; i++)
{
if (string.IsNullOrEmpty(value[i]))
{
diff --git a/src/Microsoft.AspNetCore.ResponseCaching/ResponseCacheMiddleware.cs b/src/Microsoft.AspNetCore.ResponseCaching/ResponseCachingMiddleware.cs
similarity index 85%
rename from src/Microsoft.AspNetCore.ResponseCaching/ResponseCacheMiddleware.cs
rename to src/Microsoft.AspNetCore.ResponseCaching/ResponseCachingMiddleware.cs
index 000e03137a..dc01df4fba 100644
--- a/src/Microsoft.AspNetCore.ResponseCaching/ResponseCacheMiddleware.cs
+++ b/src/Microsoft.AspNetCore.ResponseCaching/ResponseCachingMiddleware.cs
@@ -4,7 +4,6 @@
using System;
using System.Globalization;
using System.Threading.Tasks;
-using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Http.Headers;
@@ -17,25 +16,25 @@ using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNetCore.ResponseCaching
{
- public class ResponseCacheMiddleware
+ public class ResponseCachingMiddleware
{
private static readonly TimeSpan DefaultExpirationTimeSpan = TimeSpan.FromSeconds(10);
private readonly RequestDelegate _next;
- private readonly ResponseCacheOptions _options;
+ private readonly ResponseCachingOptions _options;
private readonly ILogger _logger;
- private readonly IResponseCachePolicyProvider _policyProvider;
- private readonly IResponseCacheStore _store;
- private readonly IResponseCacheKeyProvider _keyProvider;
+ private readonly IResponseCachingPolicyProvider _policyProvider;
+ private readonly IResponseCache _cache;
+ private readonly IResponseCachingKeyProvider _keyProvider;
private readonly Func