@@ -50,6 +50,25 @@ Happy hacking!
50
50
51
51
### API
52
52
53
+ #### Caching and ` write=true ` query strings
54
+
55
+ Before performing any PUT or DELETE operation, npm clients first make a
56
+ GET request to the registry resource being updated, which includes
57
+ the query string ` ?write=true ` .
58
+
59
+ The semantics of this are, effectively, "I intend to write to this thing,
60
+ and need to know the latest current value, so that my write can land
61
+ cleanly".
62
+
63
+ The public npm registry handles these ` ?write=true ` requests by ensuring
64
+ that the cache is re-validated before sending a response. In order to
65
+ maintain the same behavior on the client, and not get tripped up by an
66
+ overeager local cache when we intend to write data to the registry, any
67
+ request that comes through ` npm-registry-fetch ` that contains ` write=true `
68
+ in the query string will forcibly set the ` prefer-online ` option to ` true ` ,
69
+ and set both ` prefer-offline ` and ` offline ` to false, so that any local
70
+ cached value will be revalidated.
71
+
53
72
#### <a name =" fetch " ></a > ` > fetch(url, [opts]) -> Promise<Response> `
54
73
55
74
Performs a request to a given URL.
@@ -391,6 +410,9 @@ Force offline mode: no network requests will be done during install. To allow
391
410
This option is only really useful if you're also using
392
411
[ ` opts.cache ` ] ( #opts-cache ) .
393
412
413
+ This option is set to ` true ` when the request includes ` write=true ` in the
414
+ query string.
415
+
394
416
##### <a name =" opts-otp " ></a > ` opts.otp `
395
417
396
418
* Type: Number | String
@@ -402,7 +424,7 @@ account.
402
424
403
425
##### <a name =" opts-password " ></a > ` opts.password `
404
426
405
- * Alias: _ password
427
+ * Alias: ` _password `
406
428
* Type: String
407
429
* Default: null
408
430
@@ -432,6 +454,9 @@ will be requested from the server. To force full offline mode, use
432
454
This option is generally only useful if you're also using
433
455
[ ` opts.cache ` ] ( #opts-cache ) .
434
456
457
+ This option is set to ` false ` when the request includes ` write=true ` in the
458
+ query string.
459
+
435
460
##### <a name =" opts-prefer-online " ></a > ` opts.prefer-online `
436
461
437
462
* Type: Boolean
@@ -443,6 +468,8 @@ for updates immediately even for fresh package data.
443
468
This option is generally only useful if you're also using
444
469
[ ` opts.cache ` ] ( #opts-cache ) .
445
470
471
+ This option is set to ` true ` when the request includes ` write=true ` in the
472
+ query string.
446
473
447
474
##### <a name =" opts-project-scope " ></a > ` opts.project-scope `
448
475
@@ -606,4 +633,4 @@ See also [`opts.password`](#opts-password)
606
633
* Default: null
607
634
608
635
** DEPRECATED ** This is a legacy authentication token supported only for
609
- * compatibility. Please use [ ` opts.token ` ] ( #opts-token ) instead.
636
+ compatibility. Please use [ ` opts.token ` ] ( #opts-token ) instead.
0 commit comments