Skip to content
New issue

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

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

Already on GitHub? # to your account

are fonts cached? #23

Closed
dlcoffee opened this issue Apr 7, 2020 · 1 comment
Closed

are fonts cached? #23

dlcoffee opened this issue Apr 7, 2020 · 1 comment

Comments

@dlcoffee
Copy link

dlcoffee commented Apr 7, 2020

hi, thanks for creating this package!

i was wondering if it the fonts are supposed to be cached, and if it was possible to set the headers manually?

i checked out the https://github.com/rohanray/next-fonts-example repo, and didn't see any caching headers set on the font.

curl http://localhost:3000/fonts/Montserrat-ExtraLight.ttf -I

HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: public, max-age=0
Last-Modified: Tue, 07 Apr 2020 06:29:21 GMT
ETag: W/"3b1d0-17153543a99"
Content-Type: font/ttf
Vary: Accept-Encoding
Content-Encoding: gzip
Date: Tue, 07 Apr 2020 16:07:58 GMT
Connection: keep-alive
Transfer-Encoding: chunked

is caching handled by next or this application?

as a workaround (since i'm running nextjs behind a custom express server), i'm basically doing this:

  server.get('/fonts/*', function (req, res, next) {
    res.set('Cache-Control', 'public, max-age=31557600')
    next()
  }

to set the cache control headers manually. however, this doesn't help me if i ever decide to break away from express and go serverless.

@rohanray
Copy link
Owner

rohanray commented Apr 7, 2020

@dlcoffee : I have never handled cache in nextjs itself. For cases with nextjs export i.e. static build, I put all the resources (html, css, js) in nginx web server. Cache, HTTP headers are handled in nginx itself.

For cases with custom server i.e. nextjs in combination with express, Cache is still handled at Nginx. HTTP headers are passed onto express for further parsing and processing as required.

I hope that answers your query.

@rohanray rohanray closed this as completed Apr 7, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants