Skip to content

Commit

Permalink
feat: response cache header
Browse files Browse the repository at this point in the history
  • Loading branch information
Misaka-L committed Jan 10, 2025
1 parent afc5c79 commit 4e7617d
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions VPMReposSynchronizer.Entry/Controllers/RepoController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace VPMReposSynchronizer.Entry.Controllers;
[Route("repos")]
[Produces("application/json")]
[OutputCache(PolicyName = "vpm")]
[ResponseCache(Duration = 30)]
public class RepoController(
RepoBrowserService repoBrowserService,
RepoMetaDataService repoMetaDataService,
Expand Down
2 changes: 2 additions & 0 deletions VPMReposSynchronizer.Entry/Controllers/StatusController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace VPMReposSynchronizer.Entry.Controllers;
[ApiController]
[Route("status")]
[Produces("application/json")]
[OutputCache(PolicyName = "status")]
[ResponseCache(Duration = 10)]
public class StatusController(RepoSyncStatusService repoSyncStatusService) : ControllerBase
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace VPMReposSynchronizer.Entry.Controllers;
[Route("syncTasks")]
[Produces("application/json")]
[OutputCache(PolicyName = "status")]
[ResponseCache(Duration = 10)]
public class SyncTaskController(
RepoSyncTaskService repoSyncTaskService,
RepoMetaDataService repoMetaDataService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace VPMReposSynchronizer.Entry.Controllers;
[Route("vpm")]
[Produces("application/json")]
[OutputCache(PolicyName = "vpm")]
[ResponseCache(Duration = 30)]
public class VpmRepoController(
RepoMetaDataService repoMetaDataService,
IOptions<MirrorRepoMetaDataOptions> options,
Expand Down
4 changes: 4 additions & 0 deletions VPMReposSynchronizer.Entry/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@

#endregion

builder.Services.AddResponseCaching();

#region Others

builder.Services.AddControllers();
Expand Down Expand Up @@ -314,6 +316,8 @@

app.UseCors();

app.UseResponseCaching();

app.UseOutputCache();

if (fileHostServiceOptions.EnableRateLimit) app.UseRateLimiter();
Expand Down

0 comments on commit 4e7617d

Please sign in to comment.