简体   繁体   中英

How to cache static files when using Vapor framework for Swift

There are some css files in Public/css/. I'm accustomed to setting cache rules in the .htaccess for Apache server. How can I make the browswer cache static files when using Vapor?

Vapor serves files using its FileMiddleware . You can see that it respects the browser's use of If-None-Match , returning 304 Not Modified as appropriate.

If you need more advanced cache rules, you can roll-your-own file middleware to do this.

The better option, however, is not to use Vapor for static files and instead deploy it behind nginx (or Apache), configuring caching in the HTTP server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM