我没有加载koa-static-cache这个中间件,渲染图片会不出来。请问为啥要有静态资源服务器,没有的话图片路径有问题
还有下面这张图片这个文件缓存为什幺要分成两个目录来写,单独写一个还不行。文件路径是public文件夹下面有个images文件夹
我没有加载koa-static-cache这个中间件,渲染图片会不出来。请问为啥要有静态资源服务器,没有的话图片路径有问题
还有下面这张图片这个文件缓存为什幺要分成两个目录来写,单独写一个还不行。文件路径是public文件夹下面有个images文件夹
请看官方 README.md 开头所写的内容。
Static server for koa.
Differences between this library and other libraries such as static:
* There is no directory or index.html support.
* You may optionally store the data in memory - it streams by default.
* Caches the assets on initialization - you need to restart the process to update the assets.(can turn off with options.preload = false)
* Uses MD5 hash sum as an ETag.
* Uses .gz files if present on disk, like nginx gzip_static module
因此,你这里显然应该使用 koa-static 而不是 koa-static-cache。
3 回答2.6k 阅读✓ 已解决
1 回答968 阅读✓ 已解决
2 回答1.2k 阅读
1 回答1.1k 阅读✓ 已解决
2 回答644 阅读✓ 已解决
2 回答1.7k 阅读
2 回答1.1k 阅读
https://www.npmjs.com/package...
如果你是要访问图片的话,不应该用koa-static-cache,而是用koa-static。
项目根目录下新建 public/images
这样子你访问图片 public/images/1.jpg 是这样子的 localhost:8080/images/1.jpg