You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
NuGet.Home/accepted/2023/Add-NoHttpCacheOption.md

4.7 KiB

Add NoHttpCache option

Summary

The proposal seeks to eliminate user confusion regarding the -NoCache, --no-cache, and RestoreNoCache options in nuget.exe, dotnet.exe, and msbuild.exe respectively by introducing new options: -NoHttpCache, --no-http-cache, RestoreNoHttpCache, which clearly specify that they disables only HTTP cache caching, not the global packages folder. To ensure a smooth transition and avoid additional confusion, the old options will not be deprecated but will co-exist with the new option. Updated documentation will provide guidance on the specific functions of each option, allowing users to make informed decisions based on their caching needs.

Motivation

The motivation behind introducing the new --no-http-cache option is to enhance user experience with clarity. Existing options like -NoCache, --no-cache, and RestoreNoCache have proven to be ambiguous, leading to misunderstandings about their functionality.

Explanation

Functional explanation

Imagine you're working on a .NET project and you're using various CLI tools like dotnet.exe, nuget.exe, and msbuild.exe. You've been using the -NoCache, --no-cache, or RestoreNoCache options to disable caching, but you're a bit confused because it doesn't seem to affect the global packages folder. Well, that's because these options were designed to disable only the HTTP cache, not the global packages folder.

To make things clearer, a new CLI option has been introduced: --no-http-cache. When you use this flag, it explicitly disables only the HTTP cache, leaving the global packages folder untouched. The previous options are still there; And they will have messages to help move people towards the better named options. In addition, we will be hiding the existing --no-cache option from the CLI help output. The --no-http-cache option will be shown in the CLI help output. This will help guide users to the new option.

Here's a simple restore example:

Old way (still works): dotnet restore --no-cache New way (clearer): dotnet restore --no-http-cache

Technical explanation

The proposal is to add a new option -NoHttpCache which will set the exact same NoCache option boolean. For now if either of these options are set, NoCache will be set to true.

Drawbacks

Rationale and alternatives

This design is the best because it introduces explicitness without breaking existing workflows; the older flags are not deprecated and still work as before. Alternative designs like modifying the behavior of existing flags or deprecating them were considered but ruled out because we do not want to confuse our users.

Prior Art

  • None

Unresolved Questions

To ensure a smooth transition, the current -NoCache options will be preserved. However, we would also like our users to know this option will only stop Http caching and that there is a new option -NoHttpCache which is clearer and does the same thing. As a result, printing a log message that warns users when they use the -NoCache option is ideal. I am not sure if the following is a sufficient message
"NoCache is deprecated in favor of the appropriately named NoHttpCache."

Future Possibilities

  • None