-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Output caching middleware #41037
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Output caching middleware #41037
Changes from all commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
ecb85f0
Create output caching middleware
sebastienros 2b2685e
Fix MVC attribute
sebastienros 6380e9c
Update src/Middleware/OutputCaching/src/Policies/EnableCachingPolicy.cs
sebastienros 1790d17
Update src/Middleware/OutputCaching/src/DispatcherExtensions.cs
sebastienros 7629b38
Update src/Middleware/OutputCaching/src/Policies/PredicatePolicy.cs
sebastienros 6732dae
Update src/Middleware/OutputCaching/src/Policies/ExpirationPolicy.cs
sebastienros 92e9da4
Fix mention of response cache
sebastienros 85c5b0e
Update src/Middleware/OutputCaching/src/OutputCachingPolicyProvider.cs
sebastienros d79df7e
Use IReadOnlyList in IPoliciesMetadata
sebastienros 7a4f0be
Add XML documentation
sebastienros d80d247
Missing changes
sebastienros c3785dd
Remove unused file
sebastienros d1e3596
PR feedback
sebastienros d77fa70
Fix build
sebastienros c00ac9c
Add Path sample
sebastienros 969f4d5
Fix build
sebastienros 96d64d4
Update public api
sebastienros 59fb7bc
Fix typos
sebastienros 7d4f1a2
Update sample
sebastienros 9d0aef1
Fix build
sebastienros 69739e6
API cleaning and test project
sebastienros cd55327
Merge remote-tracking branch 'origin/main' into sebros/outputcaching
sebastienros 7155379
Update src/Middleware/OutputCaching.Abstractions/src/Microsoft.AspNet…
sebastienros 1318b0f
Update src/Middleware/OutputCaching/src/Microsoft.AspNetCore.OutputCa…
sebastienros 89b58f1
Update TrimmableProjects
sebastienros ec5167e
Fix solution
sebastienros 3dca7ba
Improve ThrowIfNull usage
sebastienros 8c745ba
API review feedback
sebastienros f19b597
Add more tests
sebastienros b7b7322
Update API
sebastienros f707120
Clean up api
sebastienros 52dfb2b
Update unit tests
sebastienros 6e02d95
Merge branch 'main' into sebros/outputcaching
sebastienros ddfbdb3
Remove CachedResponseHeaders from public API
sebastienros b9ce0f7
Fix unshipped file
sebastienros bc87951
API review feedback
sebastienros 2239c8a
Fix unit tests
sebastienros 8d6563e
Feedback
sebastienros 3c15e2a
Refactor resolved policies
sebastienros 499e8a2
Clean sample
sebastienros 4136f9d
Provide HttpContext in VaryByValue
sebastienros 8d54293
Reduce public API
sebastienros bf2b038
Merge remote-tracking branch 'origin/main' into sebros/outputcaching
sebastienros 47b7f49
Apply API review changes
sebastienros 343b25e
Add more tests
sebastienros fcbea07
Add more tests
sebastienros aa89f7c
Apply PR feedback
sebastienros 16efeac
Merge remote-tracking branch 'origin/main' into sebros/outputcaching
sebastienros edaf9ff
PR feedback
sebastienros 4013de5
PR feedback
sebastienros 37e3028
Brennan's
sebastienros 0412a3f
Update submodule (#42357)
sebastienros File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ | |
"applicationUrl": "https://localhost:61226;http://localhost:61227" | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ | |
"applicationUrl": "https://localhost:61218;http://localhost:61219" | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ | |
"applicationUrl": "https://localhost:61228;http://localhost:61229" | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ | |
"applicationUrl": "https://localhost:61220;http://localhost:61221" | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ | |
"applicationUrl": "https://localhost:61230;http://localhost:61231" | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ | |
"applicationUrl": "https://localhost:61223;http://localhost:61225" | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ | |
"applicationUrl": "https://localhost:61222;http://localhost:61224" | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"solution": { | ||
"path": "..\\..\\..\\AspNetCore.sln", | ||
"projects": [ | ||
"src\\Middleware\\OutputCaching\\samples\\OutputCachingSample\\OutputCachingSample.csproj", | ||
"src\\Middleware\\OutputCaching\\src\\Microsoft.AspNetCore.OutputCaching.csproj", | ||
"src\\Middleware\\OutputCaching\\test\\Microsoft.AspNetCore.OutputCaching.Tests.csproj" | ||
] | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/Middleware/OutputCaching/samples/OutputCachingSample/.vscode/launch.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
// Use IntelliSense to find out which attributes exist for C# debugging | ||
// Use hover for the description of the existing attributes | ||
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md | ||
"name": ".NET Core Launch (web)", | ||
"type": "coreclr", | ||
"request": "launch", | ||
"preLaunchTask": "build", | ||
// If you have changed target frameworks, make sure to update the program path. | ||
"program": "${workspaceFolder}/bin/Debug/net7.0/OutputCachingSample.dll", | ||
"args": [], | ||
"cwd": "${workspaceFolder}", | ||
"stopAtEntry": false, | ||
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser | ||
"serverReadyAction": { | ||
"action": "openExternally", | ||
"pattern": "\\bNow listening on:\\s+(https?://\\S+)" | ||
}, | ||
"env": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
}, | ||
"sourceFileMap": { | ||
"/Views": "${workspaceFolder}/Views" | ||
} | ||
}, | ||
{ | ||
"name": ".NET Core Attach", | ||
"type": "coreclr", | ||
"request": "attach" | ||
} | ||
] | ||
} |
41 changes: 41 additions & 0 deletions
41
src/Middleware/OutputCaching/samples/OutputCachingSample/.vscode/tasks.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "build", | ||
"command": "dotnet", | ||
"type": "process", | ||
"args": [ | ||
"build", | ||
"${workspaceFolder}/OutputCachingSample.csproj", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"problemMatcher": "$msCompile" | ||
}, | ||
{ | ||
"label": "publish", | ||
"command": "dotnet", | ||
"type": "process", | ||
"args": [ | ||
"publish", | ||
"${workspaceFolder}/OutputCachingSample.csproj", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"problemMatcher": "$msCompile" | ||
}, | ||
{ | ||
"label": "watch", | ||
"command": "dotnet", | ||
"type": "process", | ||
"args": [ | ||
"watch", | ||
"run", | ||
"--project", | ||
"${workspaceFolder}/OutputCachingSample.csproj" | ||
], | ||
"problemMatcher": "$msCompile" | ||
} | ||
] | ||
} |
17 changes: 17 additions & 0 deletions
17
src/Middleware/OutputCaching/samples/OutputCachingSample/Gravatar.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
public static class Gravatar | ||
{ | ||
public static async Task WriteGravatar(HttpContext context) | ||
{ | ||
const string type = "monsterid"; // identicon, monsterid, wavatar | ||
const int size = 200; | ||
var hash = Guid.NewGuid().ToString("n"); | ||
|
||
context.Response.StatusCode = 200; | ||
context.Response.ContentType = "text/html"; | ||
await context.Response.WriteAsync($"<img src=\"https://www.gravatar.com/avatar/{hash}?s={size}&d={type}\"/>"); | ||
await context.Response.WriteAsync($"<pre>Generated at {DateTime.Now:hh:mm:ss.ff}</pre>"); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/Middleware/OutputCaching/samples/OutputCachingSample/OutputCachingSample.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Reference Include="Microsoft.AspNetCore" /> | ||
<!-- Mvc.Core is referenced only for its attributes --> | ||
<Reference Include="Microsoft.AspNetCore.Mvc.Core" /> | ||
</ItemGroup> | ||
|
||
</Project> |
27 changes: 27 additions & 0 deletions
27
src/Middleware/OutputCaching/samples/OutputCachingSample/Properties/launchSettings.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:54270/", | ||
"sslPort": 44398 | ||
} | ||
}, | ||
"profiles": { | ||
"OutputCachingSample": { | ||
"commandName": "Project", | ||
"launchBrowser": true, | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
}, | ||
"applicationUrl": "https://localhost:5001;http://localhost:5000" | ||
}, | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/Middleware/OutputCaching/samples/OutputCachingSample/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
ASP.NET Core Output Caching Sample | ||
=================================== | ||
|
||
This sample illustrates the usage of ASP.NET Core output caching middleware. The application sends a `Hello World!` message and the current time. A different cache entry is created for each variation of the query string. | ||
|
||
When running the sample, a response will be served from cache when possible and will be stored for up to 10 seconds. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's our approval process these days for extending the shared framework❔ Was that process followed here❔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing apart from api review where it was discussed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know whether that's sufficient. @adityamandaleeka❔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed w/ Aditya in triage that we want this in the SharedFx