@@ -56,6 +56,25 @@ Happy hacking!
56
56
57
57
### API
58
58
59
+ #### Caching and ` write=true ` query strings
60
+
61
+ Before performing any PUT or DELETE operation, npm clients first make a
62
+ GET request to the registry resource being updated, which includes
63
+ the query string ` ?write=true ` .
64
+
65
+ The semantics of this are, effectively, "I intend to write to this thing,
66
+ and need to know the latest current value, so that my write can land
67
+ cleanly".
68
+
69
+ The public npm registry handles these ` ?write=true ` requests by ensuring
70
+ that the cache is re-validated before sending a response. In order to
71
+ maintain the same behavior on the client, and not get tripped up by an
72
+ overeager local cache when we intend to write data to the registry, any
73
+ request that comes through ` npm-registry-fetch ` that contains ` write=true `
74
+ in the query string will forcibly set the ` prefer-online ` option to ` true ` ,
75
+ and set both ` prefer-offline ` and ` offline ` to false, so that any local
76
+ cached value will be revalidated.
77
+
59
78
#### <a name =" fetch " ></a > ` > fetch(url, [opts]) -> Promise<Response> `
60
79
61
80
Performs a request to a given URL.
@@ -397,6 +416,9 @@ Force offline mode: no network requests will be done during install. To allow
397
416
This option is only really useful if you're also using
398
417
[ ` opts.cache ` ] ( #opts-cache ) .
399
418
419
+ This option is set to ` true ` when the request includes ` write=true ` in the
420
+ query string.
421
+
400
422
##### <a name =" opts-otp " ></a > ` opts.otp `
401
423
402
424
* Type: Number | String
@@ -408,7 +430,7 @@ account.
408
430
409
431
##### <a name =" opts-password " ></a > ` opts.password `
410
432
411
- * Alias: _ password
433
+ * Alias: ` _password `
412
434
* Type: String
413
435
* Default: null
414
436
@@ -438,6 +460,9 @@ will be requested from the server. To force full offline mode, use
438
460
This option is generally only useful if you're also using
439
461
[ ` opts.cache ` ] ( #opts-cache ) .
440
462
463
+ This option is set to ` false ` when the request includes ` write=true ` in the
464
+ query string.
465
+
441
466
##### <a name =" opts-prefer-online " ></a > ` opts.prefer-online `
442
467
443
468
* Type: Boolean
@@ -449,6 +474,8 @@ for updates immediately even for fresh package data.
449
474
This option is generally only useful if you're also using
450
475
[ ` opts.cache ` ] ( #opts-cache ) .
451
476
477
+ This option is set to ` true ` when the request includes ` write=true ` in the
478
+ query string.
452
479
453
480
##### <a name =" opts-project-scope " ></a > ` opts.project-scope `
454
481
@@ -612,4 +639,4 @@ See also [`opts.password`](#opts-password)
612
639
* Default: null
613
640
614
641
** DEPRECATED ** This is a legacy authentication token supported only for
615
- * compatibility. Please use [ ` opts.token ` ] ( #opts-token ) instead.
642
+ compatibility. Please use [ ` opts.token ` ] ( #opts-token ) instead.
0 commit comments