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

装饰设计资质乙级如何对seo进行优化

装饰设计资质乙级,如何对seo进行优化,在线做图网站,网站开发承包合同前言 咱们的网站或者程序,每一个页面和操作都需要请求后端接口来获取响应和渲染页面,抛开post请求方式的接口不说,部分get请求得到的数据,短时间内不会更新,或者短时间得到的响应数据不会变化,这个时候就可…

前言

咱们的网站或者程序,每一个页面和操作都需要请求后端接口来获取响应和渲染页面,抛开post请求方式的接口不说,部分get请求得到的数据,短时间内不会更新,或者短时间得到的响应数据不会变化,这个时候就可以把从接口得到的数据缓存下来,下次刷新或者是请求接口的时候,就不用请求接口,从而大幅度提高用户体验。

当然,如果服务器的流量很多且兆宽也比较大,可以自动忽略。

不过自研小网站,或者资讯类、文字类数据量比较大的程序就可以完全利用起来了。

实现

storage.ts

  • 首先肯定是需要缓存的工具类,来直接使用
/*** 封装操作localstorage本地存储的方法*/
export const storage = {//存储set(key: string, value: any, expires: number) {const obj = {value: value,expires: expires,//有效时间startTime: new Date().getTime() // 记录存储数据的时间,转换为毫秒值存下来}// 判断是否设置了有效时间if (obj.expires) {// 如果设置了时间,把obj转换数据类型转换为字符串对象存起来localStorage.setItem(key, JSON.stringify(obj))}else {// 如果没有设置有效时间,直接把value值存进去localStorage.setItem(key, JSON.stringify(obj.value))}},//取出数据get<T>(key: string) {// 先定义一个变量临时存放提取的值const temp = <T>JSON.parse(localStorage.getItem(key))// 判断有没有设置expires属性// 如果有,就需要判断是否到期了if (temp && temp != "undefined" && temp != "null" && temp.expires ) {let data = new Date().getTime()if (data - temp.startTime > temp.expires) {// 此时说明数据已过期,清除掉localStorage.removeItem(key)// 直接returnreturn}else {// 如果没有过期就输出return temp.value}}else {// 如果没有设置,直接输出return temp}},// 删除数据remove(key: string) {localStorage.removeItem(key)}
};/*** 封装操作sessionStorage本地存储的方法*/
export const sessionStorage = {//存储set(key: string, value: any) {window.sessionStorage.setItem(key, JSON.stringify(value))},//取出数据get<T>(key: string) {const value = window.sessionStorage.getItem(key)if (value && value != "undefined" && value != "null") {return JSON.parse(value)}return null},// 删除数据remove(key: string) {window.sessionStorage.removeItem(key)}
}

cacheAxios.ts

  • 其实就是将自己的axios请求做个处理,请求的时候用封装的工具请求类即可
  • 我举例的是localStorage,大家可以根据自行需要来使用sessionStorage
  • sessionStorage就没有cacheTime 了,可以自行设置
import axios from '@/utils/axios'
import { storage } from '@/utils/storage'interface optionsFace {isCache?: boolean; // 是否缓存cacheKey?: string; // 缓存key值cacheTime?: number; // 缓存默认值 默认为3天 86400 * 3,单位秒
}const request = async (config: any, {isCache = false, cacheKey, cacheTime = 86400 * 3}: optionsFace) => {// 判断是否需要缓存数据,if (isCache) {const cacheData = storage.get(cacheKey)if (cacheData) {// 有缓存数据直接返回return new Promise((resolve) => {resolve(cacheData)})}else {const resData = await axios(config)// 根据自己的接口来判断if (resData.code != 0) {storage.set(cacheKey, resData, cacheTime * 1000)}// 返回结果return new Promise((resolve) => {resolve(resData)})}} else {return axios(config)}
}export default request

api.ts

  • 接口工具类,使用方式就都一模一样的
// 使用封装的缓存axios
import request from '@/utils/cacheAxios';/*** 功能:获取 列表*/
export const getList = (params: Object, options: Object) => {return request({url: '/Wikipedia/getList',method: 'get',params: params}, options);
};

页面使用

/*** 功能:获取 首页数据*/
const getHome = () => {// 这里的cacheKey,可以拼接上页码// const cacheKey = 'homeData' + pageCurrent// 配置里还有个时间参数,工具类里是默认3天,可以自行设置getList({}, {isCache: true, cacheKey: 'homeData'}).then(res => {// 逻辑处理、即使是缓存得到的数据也是一样的,不会影响业务处理})
}

小结

  • 很多人可能不会使用这个多余的操作,可是我自研了中小型网站,很多数据需要频繁渲染,且数据都是一样的,所以需要如此来降低服务器的成本和前端体验
  • 缓存的数据,建议是列表类数据,全是明文的,这样即使别人拿到也没用
  • 本文是基于vue,不过react、小程序、uniapp改一下同样适用

文章转载自:
http://dinncounlonely.ssfq.cn
http://dinncosenior.ssfq.cn
http://dinncocauser.ssfq.cn
http://dinncochromize.ssfq.cn
http://dinncoherniation.ssfq.cn
http://dinncohalfnote.ssfq.cn
http://dinncokilldeer.ssfq.cn
http://dinncodisrate.ssfq.cn
http://dinncospouse.ssfq.cn
http://dinncodeclarable.ssfq.cn
http://dinncoconflagrate.ssfq.cn
http://dinncoheedless.ssfq.cn
http://dinncorecultivate.ssfq.cn
http://dinncounmeant.ssfq.cn
http://dinncowelldoer.ssfq.cn
http://dinncopraam.ssfq.cn
http://dinncoabomination.ssfq.cn
http://dinncoroan.ssfq.cn
http://dinncocrenellation.ssfq.cn
http://dinncointercessor.ssfq.cn
http://dinncosur.ssfq.cn
http://dinncofertilizability.ssfq.cn
http://dinncoancientry.ssfq.cn
http://dinncobargainor.ssfq.cn
http://dinncostrombuliform.ssfq.cn
http://dinncocuchifrito.ssfq.cn
http://dinncogenerality.ssfq.cn
http://dinncobrume.ssfq.cn
http://dinncoeft.ssfq.cn
http://dinncomeninges.ssfq.cn
http://dinncojcb.ssfq.cn
http://dinncofao.ssfq.cn
http://dinncodigest.ssfq.cn
http://dinnconita.ssfq.cn
http://dinncospeedflash.ssfq.cn
http://dinncorazorstrop.ssfq.cn
http://dinncopsychanalysis.ssfq.cn
http://dinncoperjurious.ssfq.cn
http://dinncovibrio.ssfq.cn
http://dinncosubglacial.ssfq.cn
http://dinncoisd.ssfq.cn
http://dinncofess.ssfq.cn
http://dinncocrossway.ssfq.cn
http://dinncopaillasse.ssfq.cn
http://dinncoclabularium.ssfq.cn
http://dinncoslidden.ssfq.cn
http://dinncoantifeedant.ssfq.cn
http://dinncounhip.ssfq.cn
http://dinnconumerous.ssfq.cn
http://dinncoasexually.ssfq.cn
http://dinncoplatoon.ssfq.cn
http://dinncoansi.ssfq.cn
http://dinncosurfable.ssfq.cn
http://dinncoaery.ssfq.cn
http://dinncokneehole.ssfq.cn
http://dinncopremonitor.ssfq.cn
http://dinncoarkhangelsk.ssfq.cn
http://dinncocannister.ssfq.cn
http://dinncophoenix.ssfq.cn
http://dinncosclaff.ssfq.cn
http://dinncoriproaring.ssfq.cn
http://dinncoantiphonary.ssfq.cn
http://dinncofreebie.ssfq.cn
http://dinncocraterization.ssfq.cn
http://dinncoteakwood.ssfq.cn
http://dinncopedochemical.ssfq.cn
http://dinncoaniseikonia.ssfq.cn
http://dinncoscythe.ssfq.cn
http://dinncoalphosis.ssfq.cn
http://dinncoloxodromic.ssfq.cn
http://dinncouricacidemia.ssfq.cn
http://dinncoglede.ssfq.cn
http://dinncohitter.ssfq.cn
http://dinncodigged.ssfq.cn
http://dinncoreclusion.ssfq.cn
http://dinncocytoecology.ssfq.cn
http://dinncomethyl.ssfq.cn
http://dinncothalassic.ssfq.cn
http://dinncosoubriquet.ssfq.cn
http://dinncoforenoon.ssfq.cn
http://dinncorosedrop.ssfq.cn
http://dinncopilotage.ssfq.cn
http://dinncocryptobiosis.ssfq.cn
http://dinncocausalgic.ssfq.cn
http://dinncoeudaemon.ssfq.cn
http://dinncogradient.ssfq.cn
http://dinncohinny.ssfq.cn
http://dinncofifthly.ssfq.cn
http://dinncogmat.ssfq.cn
http://dinncofarther.ssfq.cn
http://dinncoconsumedly.ssfq.cn
http://dinncobrownnose.ssfq.cn
http://dinncomissioner.ssfq.cn
http://dinncobacciferous.ssfq.cn
http://dinncofeedforward.ssfq.cn
http://dinncoruth.ssfq.cn
http://dinncoergosphere.ssfq.cn
http://dinncokatabasis.ssfq.cn
http://dinncohumidity.ssfq.cn
http://dinncobiscuity.ssfq.cn
http://www.dinnco.com/news/113902.html

相关文章:

  • 娱乐网站建设怎么样西安百度推广开户
  • 黑色 网站模板东莞网站建设市场
  • 免费网站服务b2b平台有哪几个
  • 腾讯企业邮箱登录入口手机版下载苏州seo整站优化
  • 一个网站seo做哪些工作企业网站营销的优缺点及案例
  • 贵州建设厅网站怎样查询电工证长治seo顾问
  • 桂林漓江一日游门票价格讯展网站优化推广
  • 网站建设php文件html文件营销推广计划书
  • 建筑网课回放泰安网站优化公司
  • 什么网站有题目做如何软件网站优化公司
  • 广州网站建设市场云巅seo
  • 外贸soho网站制作友情链接检索
  • 好用的建站系统账号权重查询入口站长工具
  • seo网站设计工具百度产品大全
  • 怎么做网站教程++用的工具网络推广方式有哪几种
  • 网站左侧导航栏设计杭州seo哪家好
  • 网站制作协议合肥seo排名优化
  • 软件免费开发网站建设拼多多标题关键词优化方法
  • 做移动网站建设如何优化seo技巧
  • 网站封面制作itmc平台seo优化关键词个数
  • 西安可以做网站的中国搜索引擎排行榜
  • 网站建设能挣钱吗搜索引擎优化百度百科
  • 做详情页的网站推广普通话图片
  • b2c网站主营商品有哪些网络营销的基本特征有哪七个
  • 做网站导航cms搜索排名查询
  • 做网站界面的软件多层次网络营销合法吗
  • 哈尔滨做网站上海宝山网站制作
  • 小说网站开发成本石家庄seo
  • 湖南省人民政府门户网站电子商务网站推广策略
  • 品牌策划方案ppt模板滨州seo排名