Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cache.enabled = ${KK_CACHE_ENABLED:false} 不起作用 #601

Open
Zea1021 opened this issue Oct 30, 2024 · 3 comments
Open

cache.enabled = ${KK_CACHE_ENABLED:false} 不起作用 #601

Zea1021 opened this issue Oct 30, 2024 · 3 comments

Comments

@Zea1021
Copy link

Zea1021 commented Oct 30, 2024

很多同名文件,但在不同的文件夹下,他们的内容是不一样的,然而每次预览都是走的缓存,预览的是同一份文件。
修改application.properties文件将缓存禁用:cache.enabled = ${KK_CACHE_ENABLED:false} ,也不起作用,还是走的缓存

@Zea1021
Copy link
Author

Zea1021 commented Oct 30, 2024

在url前面加一个forceUpdatedCache=true可以访问

@gaoxingzaq
Copy link
Contributor

恩,我们排查修复下 应该是下载方法里面有个判断文件存在就不执行下载导致的

@Zea1021
Copy link
Author

Zea1021 commented Nov 7, 2024

感谢回复。后面我看了一部分源码,那个添加缓存的键使用的cacheName有点问题,cacheName 是由“文件名+文件后缀+.pdf”组成。这样无法解决“使用不同url预览同名文件”的问题,比如文件路径为:http://localhost:8080/test1/test.doc和http://localhost:8080/test2/test.doc,他们的cacheName都是testdoc.pdf,实际上他们的内容是不同的。

建议拼接上用户传入的url路径,这样当路径不同时,即使是同名文件,他们走的也不是同一个缓存。

添加缓存的代码如下:
fileHandlerService.addConvertedFile(cacheName, fileHandlerService.getRelativePath(outFilePath));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants