2020-06-08 05:48:40 +02:00
# Favicon
2020-07-02 11:56:07 +02:00
Favicon middleware ignores favicon requests or caches a provided icon in memory to improve performance by skipping disk access. User agents request favicon.ico frequently and indiscriminately, so you may wish to exclude these requests from your logs by using this middleware before your logger middleware.
2020-06-08 05:48:40 +02:00
2020-07-02 11:56:07 +02:00
**Note** This middleware is exclusively for serving the _default, implicit favicon_ , which is `GET /favicon.ico` .
2020-06-08 05:48:40 +02:00
### Example
2020-07-02 11:56:07 +02:00
Import the middleware package that is part of the Fiber web framework
2020-06-08 05:48:40 +02:00
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/fiber/middleware"
)
2020-07-02 11:56:07 +02:00
```
2020-06-08 05:48:40 +02:00
2020-07-02 11:56:07 +02:00
After you initiate your Fiber app, you can use the following possibilities:
```go
2020-07-02 12:16:12 +02:00
func main() {
app := fiber.New()
// Default ignore favicon
app.Use(middleware.Favicon())
2020-06-08 05:48:40 +02:00
2020-07-02 12:16:12 +02:00
// Pass a favicon file that will be cached in memory
app.Use(middleware.Favicon("./favicon.ico"))
// ...
}
2020-06-08 05:48:40 +02:00
```
### Signatures
```go
func Favicon(file ...string) fiber.Handler {}
```