Structurevapor 4.114.1Vapor
CachePolicy
The browser cache policy files should be served with.
struct CachePolicy
The browser cache policy files should be served with.
struct CachePolicy
import Vapor
Vapor is a framework for building server applications, APIs and websites in Swift. It provides a safe, performant and scalable foundation for building large complex backends.
final class FileMiddleware
Serves static files from a public directory.
convenience init(bundle: Bundle, publicDirectory: String = "Public", defaultFile: String? = nil, directoryAction: DirectoryAction = .none, cachePolicy: CachePolicy = .browserDefault) throws
Creates a new FileMiddleware
for a server contained in an Xcode Project.
init(publicDirectory: String, defaultFile: String? = nil, directoryAction: DirectoryAction = .none, advancedETagComparison: Bool = false, cachePolicy: CachePolicy = .browserDefault)
Creates a new FileMiddleware
.
func respond(to request: Request, chainingTo next: any AsyncResponder) async throws -> Response
struct BundleSetupError
struct DirectoryAction
Possible actions to take when the request doesn’t have a trailing slash but matches a directory
protocol Sendable
static let browserDefault: FileMiddleware.CachePolicy
The browser’s default caching policy should be used.
static let noCache: FileMiddleware.CachePolicy
The browser will always ask before requesting the full file.
static func cacheUpToDuration(_ duration: TimeAmount) -> CachePolicy
The browser will cache the file for the specified duration.
static func custom(cacheControlHeader: HTTPHeaders.CacheControl?, ageHeader: Int? = nil) -> CachePolicy
A custom cache control policy that should be used for all files.