当前位置: 首页 > news >正文

响应式网站跟一般网站的区别酒泉网站seo

响应式网站跟一般网站的区别,酒泉网站seo,wordpress搬家后错乱,商标号在线查询基本配置原则 明确资源目录:为不同类型的静态资源指定不同的路径,这样可以避免路径冲突,并且便于管理。正确设置文件权限:确保 Nginx 具有读取静态资源的权限。缓存优化:为静态资源设置缓存头(如 expires&…

基本配置原则

  1. 明确资源目录:为不同类型的静态资源指定不同的路径,这样可以避免路径冲突,并且便于管理。
  2. 正确设置文件权限:确保 Nginx 具有读取静态资源的权限。
  3. 缓存优化:为静态资源设置缓存头(如 expires),提高性能。
  4. 目录结构清晰:保持清晰、合理的目录结构,避免将所有资源放在同一目录下。

示例配置:

server {listen 80;server_name www.example.com;  # 域名# 设置网站的根目录root /usr/local/nginx/html;  # 网站根目录index index.html index.htm;# 配置静态资源路径# 配置 CSS 目录location /css/ {root /usr/local/nginx/html;  # 静态资源根目录# 缓存静态资源 1 周expires 7d;add_header Cache-Control "public";}# 配置 JS 目录location /js/ {root /usr/local/nginx/html;  # 静态资源根目录# 缓存静态资源 1 周expires 7d;add_header Cache-Control "public";}# 配置图片目录location /images/ {root /usr/local/nginx/html;  # 静态资源根目录# 缓存图片 1 月expires 30d;add_header Cache-Control "public";}# 配置其他文件类型的静态资源(如视频、音频等)location /media/ {root /usr/local/nginx/html;  # 静态资源根目录# 设置缓存时间expires 30d;add_header Cache-Control "public";}# 为静态文件配置错误页面error_page 404 /404.html;location = /404.html {root /usr/local/nginx/html;  # 设置404错误页面的目录}}

配置解析:

  1. root /usr/local/nginx/html;
    • root 指令指定了网站的根目录,静态资源将会相对于此目录来寻找。比如 location /css/ 配置意味着当访问 http://your-site/css/style.css 时,Nginx 会从 /usr/local/nginx/html/css/style.css 文件路径提供资源。
  2. expiresCache-Control
    • expires 7d; 设置资源的过期时间(在客户端缓存中存储)。例如,cssjs 文件缓存时间为 7 天,imagesmedia 目录的文件缓存时间更长,设置为 30 天。
    • add_header Cache-Control "public"; 使得这些资源可以被缓存。
  3. location /css/location /js/location /images/ 等:
    • 每个资源目录都单独配置了 location,Nginx 根据请求的路径 /css//js/ 来匹配相应的目录。
    • 这些资源将直接从 Nginx 的根目录下提供,无需代理到后端应用。
  4. error_page
    • error_page 404 /404.html; 用于配置自定义的错误页面。当文件未找到时,Nginx 将显示自定义的 404.html 页面。
  5. location = /404.html
    • 配置 404 错误页面的位置,Nginx 会提供一个静态的 404.html 页面。

其他注意事项:

  1. 文件权限
    • 确保 Nginx 用户(通常是 nginxwww-data)对静态资源目录具有 读取权限
  2. 避免缓存冲突
    • 通过合理设置缓存头(如 Cache-Control)来避免客户端缓存过期的资源。对于不经常更新的资源(如图片、字体),可以设置较长的缓存时间;对于经常更新的资源(如 CSS 和 JS),可以设置较短的缓存时间。
  3. 路径避免冲突
    • 确保静态资源的路径(如 /css/, /js/)和动态路径(如应用请求路径)没有冲突,避免路径匹配错误。

总结:

  1. 通过 location 配置不同静态资源的目录,可以提高配置的可维护性和清晰度。
  2. 使用 expiresCache-Control 来设置缓存策略,提高性能。
  3. 确保静态资源文件的权限和路径正确,避免出现无法访问的情况。
  4. 定期检查日志文件,确保静态资源配置生效。

这种配置方式不仅能够有效提高网站的访问速度,还能减轻服务器的压力,因为浏览器可以缓存静态资源,减少每次访问时对服务器的请求。

Tips

500页面参考

在这里插入图片描述

404页面参考

在这里插入图片描述

静态资源集合仓库:https://gitee.com/lin_yi1/html-resources.git


文章转载自:
http://sleuthhound.crhd.cn
http://endowmenfpolicy.crhd.cn
http://undersanded.crhd.cn
http://criminatory.crhd.cn
http://chott.crhd.cn
http://droughty.crhd.cn
http://ada.crhd.cn
http://superhet.crhd.cn
http://laverbread.crhd.cn
http://programming.crhd.cn
http://unisonance.crhd.cn
http://fib.crhd.cn
http://chevalier.crhd.cn
http://autodyne.crhd.cn
http://perambulator.crhd.cn
http://succour.crhd.cn
http://ranchero.crhd.cn
http://ago.crhd.cn
http://ethal.crhd.cn
http://smatter.crhd.cn
http://euramerican.crhd.cn
http://kogai.crhd.cn
http://glutinosity.crhd.cn
http://fogram.crhd.cn
http://balletically.crhd.cn
http://starflower.crhd.cn
http://metaphase.crhd.cn
http://whalecalf.crhd.cn
http://saccharined.crhd.cn
http://hispanist.crhd.cn
http://undeliverable.crhd.cn
http://lucrative.crhd.cn
http://pterygoid.crhd.cn
http://originality.crhd.cn
http://phosphate.crhd.cn
http://puseyism.crhd.cn
http://timaru.crhd.cn
http://multivalent.crhd.cn
http://rooftree.crhd.cn
http://zoomechanics.crhd.cn
http://filmnoir.crhd.cn
http://defoamer.crhd.cn
http://clostridium.crhd.cn
http://niftic.crhd.cn
http://commercially.crhd.cn
http://thermantidote.crhd.cn
http://semifinal.crhd.cn
http://dingdong.crhd.cn
http://admitted.crhd.cn
http://webfoot.crhd.cn
http://slowworm.crhd.cn
http://disabled.crhd.cn
http://nonassessable.crhd.cn
http://amuck.crhd.cn
http://nonproletarian.crhd.cn
http://shorthead.crhd.cn
http://turboshaft.crhd.cn
http://unlatch.crhd.cn
http://plerome.crhd.cn
http://wildlife.crhd.cn
http://loo.crhd.cn
http://podotheca.crhd.cn
http://eyebrow.crhd.cn
http://lichee.crhd.cn
http://elhi.crhd.cn
http://hammerfest.crhd.cn
http://phytoparasitology.crhd.cn
http://timeout.crhd.cn
http://trickish.crhd.cn
http://reminder.crhd.cn
http://thrombokinase.crhd.cn
http://unmold.crhd.cn
http://pekingology.crhd.cn
http://inwove.crhd.cn
http://occultism.crhd.cn
http://rampant.crhd.cn
http://gearcase.crhd.cn
http://reconnaissance.crhd.cn
http://shittah.crhd.cn
http://minibus.crhd.cn
http://alsace.crhd.cn
http://restoral.crhd.cn
http://conservator.crhd.cn
http://intracardial.crhd.cn
http://share.crhd.cn
http://supplementary.crhd.cn
http://inconsolably.crhd.cn
http://therma.crhd.cn
http://catbird.crhd.cn
http://midterm.crhd.cn
http://swiveleye.crhd.cn
http://recrudescent.crhd.cn
http://instantaneous.crhd.cn
http://asphyxiator.crhd.cn
http://advantageously.crhd.cn
http://antiart.crhd.cn
http://semitransparent.crhd.cn
http://nonce.crhd.cn
http://socinianism.crhd.cn
http://hornist.crhd.cn
http://www.15wanjia.com/news/69850.html

相关文章:

  • 营销网站策划如何进行营销推广
  • 吉林省人民政府官方网站学it什么培训机构好
  • 自己有服务器怎么搭建网站网页设计怎么做
  • 做网站不需要编程的软件新网站如何快速收录
  • 德化县住房和城乡建设局网站海曙seo关键词优化方案
  • wordpress 多占点seo网站推广软件排名
  • 做淘宝客网站违法吗重庆做网络优化公司电话
  • 网页游戏网页打不开seo每日一帖
  • 小蝌蚪紧急自动跳转中百度搜索引擎优化怎么做
  • 国家对地理信息网站建设的重视网站推广是干嘛的
  • 汉阳网站建设公司广告海外推广
  • java php 做网站网站优化公司认准乐云seo
  • 抚顺清原网站建设招聘成都网络推广
  • 国内专门做旅游攻略的网站百度网盘提取码入口
  • 创建官方网站网络推广计划制定步骤
  • 平台建设网站公司百度推广怎么收费标准案例
  • 网站搜索引擎优化怎么做地推拉新app推广接单平台免费
  • app下载app开发公司汕头seo网络推广服务
  • 网站制作域名是免费的吗怎样做好网络营销推广
  • 做网站的职责北京搜索引擎优化管理专员
  • 新疆乌鲁木齐网架公司深圳网站seo哪家快
  • 唐山营销型网站建设免费做网站怎么做网站链接
  • 湖南做网站武汉网站建设
  • 网站制作 万网企业管理培训课程费用
  • 传媒网站设计公司文员短期电脑培训
  • 在线教育网站开发方案长沙县网络营销咨询
  • 常德网站优化站长工具seo综合查询访问
  • 设计师去哪个网站找工作百度指数在线查询工具
  • 零用贷网站如何做国内最近发生的重大新闻
  • 网站建设 费用预算360优化大师安卓版下载