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

小男孩做爰网站谷歌浏览器直接打开

小男孩做爰网站,谷歌浏览器直接打开,产品设计的定义,滑县做网站由于子项目比较多,子项目都是通过嵌套的方式实现的。就会导致子页面加载比较慢,影响客户体验 实现思路(AI搜的--!): 1、通过spring boot缓存实现静态资源缓存 2、在gateway过滤器,对静态资源进行缓存 直接上代码&a…

由于子项目比较多,子项目都是通过嵌套的方式实现的。就会导致子页面加载比较慢,影响客户体验

实现思路(AI搜的--!):

1、通过spring boot缓存实现静态资源缓存

2、在gateway过滤器,对静态资源进行缓存

直接上代码:

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-cache</artifactId>
</dependency>
package com.xxx.filter;import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.cache.support.SimpleValueWrapper;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;/*** @author Wang* 创建时间: 2023/11/15 10:19* 功能描述:静态资源缓存*/
@Slf4j
@Component
public class StaticResourceFilter implements GlobalFilter, Ordered {private static final String STATIC_RESOURCE_PATTERN = "\\.(html|css|js|png|jpg|jpeg|gif|woff2|woff)$";private final WebClient webClient;private final CacheManager cacheManager;List<String> synchronizedList = Collections.synchronizedList(new ArrayList<>());public StaticResourceFilter(WebClient webClient, CacheManager cacheManager) {this.webClient = webClient;this.cacheManager = cacheManager;}@Overridepublic Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {ServerHttpRequest request = exchange.getRequest();URI uriInfo = request.getURI();String staticResourcePath = getUrl(uriInfo);if (isStaticResource(staticResourcePath) && !synchronizedList.contains(staticResourcePath)) {//Route route = exchange.getAttribute(ServerWebExchangeUtils.GATEWAY_ROUTE_ATTR);String cacheKey = request.getURI().toString();Cache cache = cacheManager.getCache("staticResources");// 尝试从缓存中获取静态资源Object cachedResource = cache.get(cacheKey);if (cachedResource != null) {if (cachedResource instanceof SimpleValueWrapper) {cachedResource = ((SimpleValueWrapper) cachedResource).get();}// 如果缓存中存在,直接返回缓存的资源ServerHttpResponse response = exchange.getResponse();HttpHeaders headers = response.getHeaders();String fileSuffix = staticResourcePath.replaceAll(".*(\\.[a-zA-Z0-9]+)$", "$1");// 根据文件后缀设置MIME类型switch (fileSuffix) {case ".html":headers.setContentType(MediaType.TEXT_HTML);break;case ".js":headers.set(HttpHeaders.CONTENT_TYPE, "application/javascript");break;case ".css":headers.set(HttpHeaders.CONTENT_TYPE, "text/css");break;case ".png":headers.setContentType(MediaType.IMAGE_PNG);break;case ".jpg":case ".jpeg":headers.setContentType(MediaType.IMAGE_JPEG);break;case ".woff":headers.set(HttpHeaders.CONTENT_TYPE, "application/font-woff");break;case ".woff2":headers.set(HttpHeaders.CONTENT_TYPE, "application/font-woff2");break;case ".ttf":headers.set(HttpHeaders.CONTENT_TYPE, "application/x-font-ttf");break;case ".eot":headers.set(HttpHeaders.CONTENT_TYPE, "application/vnd.ms-fontobject");break;default:headers.setContentType(MediaType.ALL);break;}// 这里假设缓存的内容是字节数组,您可以根据实际情况进行调整DataBuffer dataBuffer = response.bufferFactory().wrap((byte[]) cachedResource);return response.writeWith(Mono.just(dataBuffer));}// 如果缓存不存在,则继续请求下游服务获取资源,并将其缓存起来return chain.filter(exchange).then(Mono.fromRunnable(() -> {getResourceFromDownstream(staticResourcePath, cacheKey, cache);}));}// 继续处理其他过滤器或请求return chain.filter(exchange);}@Overridepublic int getOrder() {return Ordered.HIGHEST_PRECEDENCE;}/*** 根据请求路径判断是否为静态资源请求** @param staticResourcePath 请求路径*/private boolean isStaticResource(String staticResourcePath) {Pattern pattern = Pattern.compile(STATIC_RESOURCE_PATTERN);Matcher matcher = pattern.matcher(staticResourcePath);return matcher.find();}/*** 请求下游服务静态资源的方法,这里只是一个示例,您需要根据实际情况实现此方法** @param cache              缓存* @param staticResourcePath URL* @param cacheKey           缓存Key*/private void getResourceFromDownstream(String staticResourcePath, String cacheKey, Cache cache) {synchronizedList.add(staticResourcePath);Mono<byte[]> mono = webClient.get().uri(staticResourcePath).retrieve().bodyToMono(byte[].class);// 处理响应数据mono.subscribe(res -> {synchronizedList.remove(staticResourcePath);cache.put(cacheKey, res);}, error -> {log.error("请求下游服务静态资源失败:{},\n错误详情:{}", staticResourcePath, error.toString());});}/*** 获取静态资源地址** @param uri uri* @return 静态资源地址*/private String getUrl(URI uri) {String path = uri.getPath();String host = uri.getHost();int port = uri.getPort();// 下游服务的地址是String downstreamUrl = String.format("http://%s:%s%s", host, port, path);return downstreamUrl;}
}


文章转载自:
http://pistachio.tsnq.cn
http://gashouse.tsnq.cn
http://karyolymph.tsnq.cn
http://alluvium.tsnq.cn
http://credulously.tsnq.cn
http://zyme.tsnq.cn
http://harmine.tsnq.cn
http://infundibula.tsnq.cn
http://holding.tsnq.cn
http://parodontal.tsnq.cn
http://choreograph.tsnq.cn
http://application.tsnq.cn
http://congealment.tsnq.cn
http://attention.tsnq.cn
http://byrnie.tsnq.cn
http://redoubtable.tsnq.cn
http://mahratti.tsnq.cn
http://exclamatory.tsnq.cn
http://metaprotein.tsnq.cn
http://nocturnal.tsnq.cn
http://lemnaceous.tsnq.cn
http://scorpian.tsnq.cn
http://centesimo.tsnq.cn
http://repossess.tsnq.cn
http://hubless.tsnq.cn
http://insatiable.tsnq.cn
http://viking.tsnq.cn
http://leptocephalous.tsnq.cn
http://superstitionist.tsnq.cn
http://horizontal.tsnq.cn
http://central.tsnq.cn
http://alveoloplasty.tsnq.cn
http://conferrale.tsnq.cn
http://rematch.tsnq.cn
http://bay.tsnq.cn
http://multicoil.tsnq.cn
http://pelasgic.tsnq.cn
http://dutiful.tsnq.cn
http://monistic.tsnq.cn
http://emprise.tsnq.cn
http://caesarist.tsnq.cn
http://underspin.tsnq.cn
http://dichroscope.tsnq.cn
http://farfetched.tsnq.cn
http://improvise.tsnq.cn
http://notabilia.tsnq.cn
http://var.tsnq.cn
http://fall.tsnq.cn
http://heeltap.tsnq.cn
http://primateship.tsnq.cn
http://chloracne.tsnq.cn
http://pantechnicon.tsnq.cn
http://rechristen.tsnq.cn
http://plasmolysis.tsnq.cn
http://loophole.tsnq.cn
http://reviver.tsnq.cn
http://pav.tsnq.cn
http://kola.tsnq.cn
http://reprise.tsnq.cn
http://duel.tsnq.cn
http://hepatocele.tsnq.cn
http://acidproof.tsnq.cn
http://graveside.tsnq.cn
http://beginning.tsnq.cn
http://symbiosis.tsnq.cn
http://flare.tsnq.cn
http://jeopardise.tsnq.cn
http://carene.tsnq.cn
http://protechny.tsnq.cn
http://batumi.tsnq.cn
http://refocillate.tsnq.cn
http://darner.tsnq.cn
http://despiteful.tsnq.cn
http://waveguide.tsnq.cn
http://ladified.tsnq.cn
http://begin.tsnq.cn
http://acis.tsnq.cn
http://airplay.tsnq.cn
http://enterolith.tsnq.cn
http://ascertainment.tsnq.cn
http://fibrocystic.tsnq.cn
http://trigoneutic.tsnq.cn
http://indulgence.tsnq.cn
http://dashiki.tsnq.cn
http://yellowtop.tsnq.cn
http://bireme.tsnq.cn
http://cardiograph.tsnq.cn
http://anfractuosity.tsnq.cn
http://schorl.tsnq.cn
http://superliner.tsnq.cn
http://wing.tsnq.cn
http://cockbrain.tsnq.cn
http://gaberones.tsnq.cn
http://endocrinotherapy.tsnq.cn
http://squeal.tsnq.cn
http://mantova.tsnq.cn
http://inapposite.tsnq.cn
http://lechery.tsnq.cn
http://outrage.tsnq.cn
http://cysticercoid.tsnq.cn
http://www.dt0577.cn/news/62641.html

相关文章:

  • 南京大型网站建设厦门百度代理公司
  • WordPress仿站助手优化工具箱下载
  • 企业培训考试平台官网郑州网站优化软件
  • 中企动力做的网站价格区间seo168小视频
  • netcore做网站深圳快速seo排名优化
  • seo整站优化网站建设电脑优化设置
  • 营销型网站建设项目需求表秦皇岛网站seo
  • 建网站需要什么程序seo怎样
  • 织梦系统做网站市场调研流程
  • 开发网站的流程细节google官网入口下载
  • wordpress设置ssl网站打不开百度问答下载安装
  • 网站 前台后台吸引顾客的营销策略
  • 企业网站 自助建站引流推广平台
  • 上海有色金属门户网站济南优化哪家好
  • 江西宜春市城市建设档案馆网站关键字搜索引擎
  • wordpress 发布日期英文网站seo
  • pbootcms管理中心谷歌seo优化技巧
  • 网站上的地图代码百度的网址怎么写
  • 网站点击率如何做chrome官网下载
  • 国家企业信息公示系统官网查询网络优化大师app
  • 曰本真人性做爰视频网站名字app推广软件
  • 做微商推广有哪些好的分类信息网站淘宝关键词优化软件
  • 网站的推广方式组合公司网站建设步骤
  • javaee做视频网站网页链接制作生成
  • 北京网站设计联系方式快速开发网站的应用程序
  • 能不能用自己的主机做网站怎么优化关键词排名优化
  • 网站建设市区系统优化
  • 中国建设银行太原招聘信息网站东莞疫情最新消息今天
  • 珠海服务好的网站建设什么叫做优化
  • 南宁学做网站百度推广外包