Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
HTML缓存字体文件_Html_Laravel_Caching_Fonts_Font Face - Fatal编程技术网

HTML缓存字体文件

HTML缓存字体文件,html,laravel,caching,fonts,font-face,Html,Laravel,Caching,Fonts,Font Face,编辑: 使用laravel框架 如何缓存字体文件而不是每次都获取新的副本 使用.htaccess,您可以实施您的解决方案。这是代码 # Fonts # Add correct content-type for fonts AddType application/vnd.ms-fontobject .eot AddType application/x-font-ttf .ttf AddType application/x-font-opentype .otf AddType applicatio

编辑: 使用laravel框架

如何缓存字体文件而不是每次都获取新的副本


使用.htaccess,您可以实施您的解决方案。这是代码

# Fonts
# Add correct content-type for fonts
AddType application/vnd.ms-fontobject .eot 
AddType application/x-font-ttf .ttf
AddType application/x-font-opentype .otf
AddType application/x-font-woff .woff
AddType image/svg+xml .svg

# Compress compressible fonts
# only uncomment if you dont have compression turned on already. Otherwise it will cause all other filestypes not to get compressed
# AddOutputFilterByType DEFLATE application/x-font-ttf application/x-font-opentype image/svg+xml

ExpiresActive on

# Add a far future Expires header for fonts
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
ExpiresByType application/x-font-ttf "access plus 1 year"
ExpiresByType application/x-font-opentype "access plus 1 year"
ExpiresByType application/x-font-woff "access plus 1 year"
ExpiresByType application/font-woff2  "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 year"

使用.htaccess可以实现您的解决方案。这是代码

# Fonts
# Add correct content-type for fonts
AddType application/vnd.ms-fontobject .eot 
AddType application/x-font-ttf .ttf
AddType application/x-font-opentype .otf
AddType application/x-font-woff .woff
AddType image/svg+xml .svg

# Compress compressible fonts
# only uncomment if you dont have compression turned on already. Otherwise it will cause all other filestypes not to get compressed
# AddOutputFilterByType DEFLATE application/x-font-ttf application/x-font-opentype image/svg+xml

ExpiresActive on

# Add a far future Expires header for fonts
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
ExpiresByType application/x-font-ttf "access plus 1 year"
ExpiresByType application/x-font-opentype "access plus 1 year"
ExpiresByType application/x-font-woff "access plus 1 year"
ExpiresByType application/font-woff2  "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 year"

据我所知,通常字体文件并不总是得到更新,对吗?但是,如果我们需要刷新字体文件的缓存,如果我实现了你的.htaccess解决方案,我是否可以使用例如myfontfile.ttf?v=1.1版本控制来刷新缓存?抱歉,我添加了laravel framework,如果这会影响任何可能的解决方案据我所知,通常字体文件并不总是得到正确更新?但是,如果我们需要刷新字体文件的缓存,如果我实现了你的.htaccess解决方案,我是否可以使用例如myfontfile.ttf?v=1.1版本控制来刷新缓存?抱歉,如果这会影响任何可能的解决方案,我添加了laravel framework