Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit d8ea54d

Browse files
committed
Docs for disabling cache, Wrangler disable updater, bump to 1.3.3
1 parent 5c1dfba commit d8ea54d

File tree

11 files changed

+78
-27
lines changed

11 files changed

+78
-27
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# 🚧 Changelog
22

3+
## 1.3.3
4+
5+
### Features
6+
7+
- Added an option to disable default and named caches. When disabled, the caches
8+
will still be available in the sandbox, they just won't cache anything. Thanks
9+
[@frandiox](https://github.com/frandiox) for the suggestion. See
10+
[✨ Cache](https://miniflare.dev/cache.html#disabling) for more details.
11+
- Added the corresponding `wrangler.toml` key for the `--disable-updater` flag:
12+
`miniflare.disable_updater`
13+
14+
### Fixes
15+
16+
- Fixed the `package.json` file path the update checker checked against
17+
318
## 1.3.2
419

520
### Features

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ Options:
9999
-k, --kv KV namespace to bind [array]
100100
--kv-persist Path to persist KV data to (omit path for default)
101101
--cache-persist Path to persist cached data to (omit path for default)
102+
--disable-cache Disable caching with default/named caches [boolean]
102103
-s, --site Path to serve Workers Site files from [string]
103104
--site-include Glob pattern of site files to serve [array]
104105
--site-exclude Glob pattern of site files not to serve [array]

docs/cache.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,25 @@ await cache.put(
100100
res = await mf.dispatchFetch("http://localhost:8787");
101101
console.log(await res.text()); // 2
102102
```
103+
104+
## Disabling
105+
106+
Both default and named caches can be disabled with the `disableCache` option.
107+
When disabled, the caches will still be available in the sandbox, they just
108+
won't cache anything. This may be useful during development:
109+
110+
```shell
111+
$ miniflare --disable-cache
112+
```
113+
114+
```toml
115+
# wrangler.toml
116+
[miniflare]
117+
disable_cache = true
118+
```
119+
120+
```js
121+
const mf = new Miniflare({
122+
disableCache: true,
123+
});
124+
```

docs/cli.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ Options:
174174
-k, --kv KV namespace to bind [array]
175175
--kv-persist Path to persist KV data to (omit path for default)
176176
--cache-persist Path to persist cached data to (omit path for default)
177+
--disable-cache Disable caching with default/named caches [boolean]
177178
-s, --site Path to serve Workers Site files from [string]
178179
--site-include Glob pattern of site files to serve [array]
179180
--site-exclude Glob pattern of site files not to serve [array]
@@ -235,13 +236,15 @@ globs = ["**/*.js"]
235236
upstream = "https://miniflare.dev" ## --upstream
236237
kv_persist = true ## --kv-persist
237238
cache_persist = "./cache" ## --cache-persist
239+
disable_cache = true ## --disable-cache
238240
durable_objects_persist = true ## --do-persist
239241
env_path = ".env.test" ## --env
240242
host = "127.0.0.1" ## --host
241243
port = 1337 ## --port
242244
wasm_bindings = [ ## --wasm
243245
{ name = "MODULE", path="module.wasm" }
244246
]
247+
disable_updater = true ## --disable-updater
245248
https = true ## --https
246249
https = "./cert_cache" ## --https ./cert_cache
247250
[miniflare.https]

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "miniflare",
3-
"version": "1.3.2",
3+
"version": "1.3.3",
44
"description": "Fun, full-featured, fully-local simulator for Cloudflare Workers",
55
"keywords": [
66
"cloudflare",

src/cli.ts

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -304,29 +304,31 @@ if (module === require.main) {
304304
const mf = new Miniflare(options);
305305

306306
mf.getOptions()
307-
.then(async ({ host, port = defaultPort, processedHttps }) => {
308-
const secure = processedHttps !== undefined;
309-
(await mf.createServer(secure as any)).listen(port, host, async () => {
310-
const protocol = secure ? "https" : "http";
311-
mf.log.info(`Listening on ${host ?? ""}:${port}`);
312-
if (host) {
313-
mf.log.info(`- ${protocol}://${host}:${port}`);
314-
} else {
315-
for (const accessibleHost of getAccessibleHosts(true)) {
316-
mf.log.info(`- ${protocol}://${accessibleHost}:${port}`);
307+
.then(
308+
async ({ host, port = defaultPort, processedHttps, disableUpdater }) => {
309+
const secure = processedHttps !== undefined;
310+
(await mf.createServer(secure as any)).listen(port, host, async () => {
311+
const protocol = secure ? "https" : "http";
312+
mf.log.info(`Listening on ${host ?? ""}:${port}`);
313+
if (host) {
314+
mf.log.info(`- ${protocol}://${host}:${port}`);
315+
} else {
316+
for (const accessibleHost of getAccessibleHosts(true)) {
317+
mf.log.info(`- ${protocol}://${accessibleHost}:${port}`);
318+
}
317319
}
318-
}
319320

320-
// Check for updates, ignoring errors (it's not that important)
321-
if (options.disableUpdater) return;
322-
try {
323-
// Get currently installed package metadata
324-
const pkgFile = path.join(__dirname, "..", "..", "package.json");
325-
const pkg = JSON.parse(await fs.readFile(pkgFile, "utf8"));
326-
const cachePath = envPaths(pkg.name).cache;
327-
await updateCheck({ pkg, cachePath, log: mf.log });
328-
} catch {}
329-
});
330-
})
321+
// Check for updates, ignoring errors (it's not that important)
322+
if (disableUpdater) return;
323+
try {
324+
// Get currently installed package metadata
325+
const pkgFile = path.join(__dirname, "..", "package.json");
326+
const pkg = JSON.parse(await fs.readFile(pkgFile, "utf8"));
327+
const cachePath = envPaths(pkg.name).cache;
328+
await updateCheck({ pkg, cachePath, log: mf.log });
329+
} catch (e) {}
330+
});
331+
}
332+
)
331333
.catch((err) => mf.log.error(err));
332334
}

src/options/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export function logOptions(log: Log, options: ProcessedOptions): void {
141141
"KV Namespaces": options.kvNamespaces,
142142
"KV Persistence": options.kvPersist,
143143
"Cache Persistence": options.cachePersist,
144-
"Disable Cache": options.disableCache,
144+
"Cache Disabled": options.disableCache,
145145
"Workers Site Path": options.sitePath,
146146
"Workers Site Include": options.siteIncludeRegexps,
147147
// Only include excludeRegexps if there are no includeRegexps

src/options/wrangler.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ interface WranglerEnvironmentConfig {
5252
upstream?: string;
5353
kv_persist?: boolean | string;
5454
cache_persist?: boolean | string;
55+
disable_cache?: boolean;
5556
durable_objects_persist?: boolean | string;
5657
env_path?: string;
5758
host?: string;
@@ -67,6 +68,7 @@ interface WranglerEnvironmentConfig {
6768
passphrase?: string;
6869
};
6970
wasm_bindings?: { name: string; path: string }[];
71+
disable_updater?: boolean;
7072
};
7173
}
7274

@@ -159,6 +161,7 @@ export function getWranglerOptions(
159161
upstream: config.miniflare?.upstream,
160162
kvPersist: config.miniflare?.kv_persist,
161163
cachePersist: config.miniflare?.cache_persist,
164+
disableCache: config.miniflare?.disable_cache,
162165
durableObjectsPersist: config.miniflare?.durable_objects_persist,
163166
envPath: config.miniflare?.env_path,
164167
host: config.miniflare?.host,
@@ -180,5 +183,6 @@ export function getWranglerOptions(
180183
},
181184
{} as Record<string, string>
182185
),
186+
disableUpdater: config.miniflare?.disable_updater,
183187
};
184188
}

test/options/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ test("logOptions: logs all options", (t) => {
7878
"- KV Namespaces: NAMESPACE1, NAMESPACE2",
7979
"- KV Persistence: kv-data",
8080
"- Cache Persistence: false",
81-
"- Disable Cache: true",
81+
"- Cache Disabled: true",
8282
"- Workers Site Path: public",
8383
"- Workers Site Include: regexp1, regexp2",
8484
"- Durable Objects: OBJECT1, OBJECT2",

0 commit comments

Comments
 (0)