Skip to content

Optimize MSGraph OpenApi specs caching based on e-tag - #1379

Merged
waldekmastykarz merged 18 commits into
dotnet:mainfrom
bartizan:1377_msgraph-spec-etag-conditional-downloading
Sep 11, 2025
Merged

waldekmastykarz merged 18 commits into
dotnet:mainfrom
bartizan:1377_msgraph-spec-etag-conditional-downloading

Conversation

@bartizan

@bartizan bartizan commented Sep 3, 2025

Copy link
Copy Markdown
Contributor

@bartizan
bartizan marked this pull request as ready for review September 3, 2025 10:37
@bartizan
bartizan requested a review from a team as a code owner September 3, 2025 10:37
@waldekmastykarz

Copy link
Copy Markdown
Collaborator

Cool! We'll review it asap

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR optimizes the MSGraph OpenAPI specs caching mechanism by implementing e-tag based conditional HTTP requests to avoid unnecessary downloads when the remote specs haven't changed.

  • Adds e-tag support to track remote file changes and avoid redundant downloads
  • Refactors the database generation flow to handle cases where specs haven't changed
  • Improves file handling and database transaction management

Comment thread DevProxy.Abstractions/Data/MSGraphDb.cs Outdated
Comment thread DevProxy.Abstractions/Data/MSGraphDb.cs Outdated
Comment thread DevProxy.Abstractions/Data/MSGraphDb.cs Outdated

@waldekmastykarz waldekmastykarz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool! I've done a few cosmetic fixes but it works like a charm.

Comment thread DevProxy.Abstractions/Data/MSGraphDb.cs Outdated
@waldekmastykarz waldekmastykarz linked an issue Sep 11, 2025 that may be closed by this pull request
@waldekmastykarz
waldekmastykarz enabled auto-merge (squash) September 11, 2025 05:40
@waldekmastykarz
waldekmastykarz merged commit 48a4024 into dotnet:main Sep 11, 2025
4 checks passed
@bartizan
bartizan deleted the 1377_msgraph-spec-etag-conditional-downloading branch September 11, 2025 07:13
}

private static string GetGraphOpenApiYamlFileName(string version) => $"graph-{version.Replace(".", "_", StringComparison.OrdinalIgnoreCase)}-openapi.yaml";
private static bool IsModifiedToday(FileInfo fileInfo) => fileInfo.Exists && fileInfo.LastWriteTime.Date == DateTime.Now.Date;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could probably use DateTime.Today instead of DateTime.Now.Date

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Would you be willing to submit a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimize MSGraph OpenApi specs caching based on e-tag

4 participants