Electronic device and request processing method

By adopting the lightweight HTTP protocol to cache static resources and generate dynamic resources on demand in edge microservers, the memory overflow and high parsing overhead problems of Web servers on resource-limited microprocessors are solved, and efficient network services are achieved.

CN120389993BActive Publication Date: 2025-09-16INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510884369.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-27
Publication Date
2025-09-16
Estimated Expiration
2045-06-27

AI Technical Summary

Technical Problem

In edge microservers, since web servers rely on operating systems and complex protocol stacks, they are difficult to directly port to microprocessors with limited resources, resulting in problems such as memory overflow and high parsing overhead.

Method used

It uses the lightweight HTTP protocol to cache static resources and generate dynamic resources on demand, reducing parsing overhead and achieving efficient network services.

Benefits of technology

By caching static resources and generating dynamic resources on demand, the processor load is reduced, the response time is shortened, the efficiency of dynamic content generation is improved, and latency is reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120389993B_ABST
    Figure CN120389993B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides an electronic device and a request processing method, which can be applied to the field of embedded technology. The electronic device may include: a first memory configured to cache multiple static resources; a processor configured to: in response to a received resource request sent based on a lightweight hypertext transfer protocol, when the resource type indicated by the resource request is a static resource, obtain a first target static resource from multiple static resources cached in the first memory according to the resource path indicated by the resource request, and send a first response message including the first target static resource to the client, wherein the lightweight hypertext transfer protocol is obtained using a simplified hypertext transfer protocol; when the resource type indicated by the resource request is a dynamic resource, execute a dynamic processing process to obtain a dynamic resource, and send a second response message including the dynamic resource to the client, wherein the dynamic processing process is used to generate a dynamic resource based on the resource request.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of embedded technology, and specifically to an electronic device and a request processing method. Background Art

[0002] Edge computing supports iterative optimization for 5G (fifth generation mobile networks), the Internet of Things, and artificial intelligence. Edge servers, which provide edge computing, are also increasing their share of the server market. Within the edge server market, there are edge microservers. Edge microservers are compact, low-cost, flexible to develop and deploy, and widely applicable.

[0003] To further reduce the cost of edge microservers, a microprocessor can replace the baseboard management controller (BMC), allowing the microprocessor to perform some of the BMC's functions. Because the development and use of microprocessors are black boxes, a web (World Wide Web) server based on a network interface can be developed to better control the microprocessor. This allows the microprocessor to be controlled and information displayed via web pages.

[0004] Developing a web server based on a network interface has the problem of high request parsing overhead. Summary of the Invention

[0005] In view of the above problems, embodiments of the present application provide an electronic device and a request processing method for reducing parsing overhead.

[0006] According to a first aspect of an embodiment of the present application, an electronic device is provided, which may include: a first memory configured to cache multiple static resources; a processor configured to: in response to a received resource request sent based on a lightweight hypertext transfer protocol, when the resource type indicated by the resource request is a static resource, obtain a first target static resource from the multiple static resources cached in the first memory according to the resource path indicated by the resource request, and send a first response information including the first target static resource to a client, wherein the lightweight hypertext transfer protocol is obtained using a simplified hypertext transfer protocol; when the resource type indicated by the resource request is a dynamic resource, execute a dynamic processing flow to obtain a dynamic resource, and send a second response information including the dynamic resource to the client, wherein the dynamic processing flow is used to generate the dynamic resource based on the resource request.

[0007] According to the second aspect of the embodiment of the present application, a request processing method is provided, which can be applied to the electronic device described in the embodiment of the present application. The method may include: in response to a received resource request sent based on the lightweight hypertext transfer protocol, when the resource type indicated by the resource request is a static resource, according to the resource path indicated by the resource request, obtaining a first target static resource from multiple static resources cached in the first memory, and sending a first response information including the first target static resource to the client, wherein the lightweight hypertext transfer protocol is obtained using the simplified hypertext transfer protocol; when the resource type indicated by the resource request is a dynamic resource, executing a dynamic processing process to obtain a dynamic resource, and sending a second response information including the dynamic resource to the client, wherein the dynamic processing process is used to generate the dynamic resource based on the resource request.

[0008] According to a third aspect of an embodiment of the present application, a computer-readable storage medium is further provided, on which a computer program or instructions are stored. When the computer program or instructions are executed by a processor, the steps of the above method are implemented.

[0009] According to a fourth aspect of an embodiment of the present application, a computer program product is also provided, including a computer program or instructions, which implement the steps of the above method when the above computer program or instructions are executed by a processor. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] The above contents and other objects, features and advantages of the present application will become more apparent through the following description of the embodiments of the present application with reference to the accompanying drawings, in which:

[0011] Figure 1 A block diagram of a request processing system according to an embodiment of the present application is shown;

[0012] Figure 2 A flowchart of a request method applied to an electronic device according to an embodiment of the present application is shown;

[0013] Figure 3 A flowchart of a request method applied to a client according to an embodiment of the present application is shown;

[0014] Figure 4 A block diagram of an electronic device for processing a request according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0015] Hereinafter, embodiments of the present application will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present application. In the detailed description below, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present application. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessarily confusing the concepts of the present application.

[0016] The terms used herein are only for describing specific embodiments and are not intended to limit this application. The terms "comprise," "include," etc. used herein indicate the presence of the features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.

[0017] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.

[0018] When expressions such as "at least one of A, B, or C" are used, they should generally be interpreted in accordance with the meaning commonly understood by those skilled in the art (for example, "a system having at least one of A, B, or C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, A, B, and C, etc.).

[0019] In the embodiment of the present application, "indication" may include direct indication, indirect indication, explicit indication or implicit indication. In the case of describing that a certain indication information is used to indicate A, it can be understood that the indication information carries A, directly indicates A or indirectly indicates A.

[0020] In the embodiments of the present application, the various numerical numbers involved are only used for the convenience of description and are not used to limit the scope of protection of this application. The size of the serial numbers involved in the embodiments of the present application does not mean the order of execution. The order of execution of each process should be determined by its function and internal logic. For example, the terms "first", "second", "third", "fourth" and other various terminology labels (if any) in the description, claims and drawings of the embodiments of the present application can be used to distinguish similar objects, and do not have to be used to describe a specific order or sequence. Among them, the terms used in this way are interchangeable where appropriate.

[0021] Unless otherwise specified or there is no logical conflict, the terms and / or descriptions between different embodiments of the present application are consistent and can be referenced by each other. The technical features in different embodiments can be combined to form new embodiments according to their internal logical relationships.

[0022] In order to clearly describe the technical solutions of the embodiments of the present application, some terms involved in the embodiments of the present application are explained below.

[0023] 1. TCP / IP (Transmission Control Protocol / Internet Protocol) protocol, link layer, network layer, transport layer, application layer

[0024] The TCP / IP protocol suite interconnects various systems on the Internet. The TCP / IP protocol consists of the link layer (or data link layer or network interface layer), the network layer (or internet layer), the transport layer, and the application layer. The link layer includes the device drivers in the operating system and the computer's physical interface. The physical interface converts digital signals into analog signals, and vice versa. The Ethernet driver is the software interface between the link layer's physical interface and the network layer. Network layer data must first pass through the Ethernet driver, which packages the network layer data and sends it over the physical interface. Upon receiving the data, the Ethernet driver processes it in a form suitable for the application layer.

[0025] The network layer may include the IP protocol, which provides unreliable and connectionless services.

[0026] The transport layer provides end-to-end communication between two devices. It can include protocols like TCP and UDP (User Datagram Protocol). TCP provides comprehensive error checking, while UDP provides a lower level of error checking.

[0027] The application layer may include HTTP (HyperText Transfer Protocol). The HTTP protocol may include HTTP requests and HTTP responses.

[0028] An HTTP request can include a request line, request headers, and a request body. The request line can be expressed as "<request method><request target><HTTP version>". The "request method" can define the type of operation. For example, the request method can include GET, POST, or PUT. GET can be used to return the content of the document pointed to by the URL (Uniform Resource Locator). For example, it can be used to request the download of a web page. POST can be used to request the server to receive a specified document without replacing the existing document, but only append new data to the data. POST can send forms that can be filled in by interactive users. POST can be used to submit data. PUT can be used to update resources. The request target can be the resource path of the request. The resource path can include a URL.

[0029] Request headers can include basic headers, cache control, content negotiation, authentication and security, and information related to the request body. Basic headers can include User-Agent (i.e., the client identifier). Content negotiation can include Accept-Encoding (i.e., the accepted encoding). Information related to the request body can include at least one of the following: Content-Type (i.e., the type of the request body) or Content-Length (i.e., the length of the request body). The request body can be used to transmit actual data.

[0030] An HTTP response can include a status line, response headers, and a response body. The status line can include the HTTP version, status code, and status text. The status code can include basic status codes. For example, the basic status codes can include at least one of the following: 200 OK (i.e., the client request was successful), 400 Bad Request (i.e., there is a syntax error in the client request), 403 Forbidden (i.e., the server received the request but refused to provide service), 404 Not Found (i.e., the requested resource does not exist), or 500 Internet Server Error (i.e., an unexpected error occurred on the server). The response headers are information provided by the server to the client about the requested document or the status of the server. The response body can include response information.

[0031] 2. HTML (Hyper Text Markup Language), CSS (Cascading Style Sheets), client-side scripts

[0032] HTML is a markup language used on the World Wide Web (WWW). It provides multimedia information and hyperlinks, transforming the Internet from text-only browsing to multimedia browsing that integrates text, images, and sound. HTML files can include HTML elements, element attributes, and their associated attribute values.

[0033] CSS is a standard language for defining the style and layout of how pages are presented in documents such as HTML. CSS can be introduced in at least one of the following ways: inline, internal, or external. For example, style code can be added to the style attribute of a tag, which cannot be implemented inline in a reused way. CSS selectors can be used to locate HTML elements and apply styles to them. CSS selectors can include at least one of the following: basic selectors, combined selectors, attribute selectors, or pseudo-class selectors. Basic selectors can include at least one of the following: element selectors, class selectors, identifier selectors, or wildcard selectors. Combined selectors can include at least one of the following: descendant selectors, child selectors, adjacent sibling selectors, or universal sibling selectors.

[0034] Client-side scripting can refer to JavaScript (JS). JavaScript is an object-based, event-driven, and relatively secure client-side scripting language. Client-side scripting can be embedded in HTML, respond to browser events, manipulate HTML elements, dynamically manipulate CSS styles, or validate data before sending it to the server.

[0035] 3. Static resources, dynamic resources, pages, static resource requests, dynamic resource requests

[0036] Resource types can include static resources or dynamic resources. Static resources can include at least one of the following: an HTML file, a CSS file, a client-side script file, or an image. Dynamic resources can refer to resources that change within a first predetermined period of time. For example, dynamic resources can include sensor data.

[0037] Based on this, a page can include HTML documents, CSS, client-side scripts or images, etc. The HTML document is the basis of the page, CSS completes the layout of the page style, and the client-side script is responsible for the behavior of the page.

[0038] HTML can load corresponding static resources such as client scripts, CSS or images according to target requirements. It can also load dynamic resources according to target requirements and use the loaded static and dynamic resources to complete the rendering of the front-end page.

[0039] The static resource request may be a resource request indicating that the resource type is a static resource.

[0040] The dynamic resource request may be a resource request indicating that the resource type is a dynamic resource.

[0041] 4. Baseboard management controller, non-programmable devices, programmable devices

[0042] A baseboard management controller may refer to an independent microcomputer embedded on a server motherboard. The baseboard management controller may be used for out-of-band management. For example, the baseboard management controller may be used for at least one of device information management, server status detection, server status management, remote control management of a server, maintenance management of a server, or hardware monitoring. The baseboard management controller may communicate with at least one of a programmable device or a non-programmable device through a communication protocol. A non-programmable device may refer to an integrated circuit with a fixed logic function that is difficult to modify through programming. For example, a non-programmable device may include at least one of the following: an analog sensor, a digital sensor, or a dedicated integrated circuit. A programmable device may refer to an integrated circuit whose logic function is configured through programming. For example, a programmable device may include at least one of the following: a programmable logic device, a complex programmable logic device, a field programmable gate array, a programmable logic array, a programmable array logic, or a general array logic.

[0043] Edge computing supports the iterative optimization of technologies like 5G, the Internet of Things, and artificial intelligence. Edge servers, which provide edge computing, are also increasing their share of the server market. Within the edge server market, there are edge microservers. These servers are compact, low-cost, flexible to develop and deploy, and widely applicable.

[0044] To further reduce the cost of edge microservers, a microprocessor can replace the baseboard management controller (BMC). This allows the microprocessor to perform some of the BMC's functions, such as power-on and power-off control, sensor data acquisition, and thermal management. Because microprocessors are typically developed and used as black boxes, a web server based on a network interface can be developed to better control the microprocessor. This allows the microprocessor to be controlled and information displayed via web pages.

[0045] During the implementation of the present invention, we discovered that Web servers, due to their reliance on operating systems and complex protocol stacks, are difficult to port directly to resource-constrained microprocessors. For example, Web servers have high resource usage, requiring a significant amount of memory for protocol parsing, dynamic resource generation, and concurrent connection management, which can lead to memory overflows.

[0046] To this end, an embodiment of the present application provides an electronic device for processing a request, which may be a resource-constrained device, and implements efficient network services through a multi-dimensional resource management strategy.

[0047] For example, the electronic device may include a first memory configured to cache multiple static resources to enable static resources to be obtained from the cache, and to generate dynamic resources in an on-demand manner, and the electronic device and the client perform data transmission based on the lightweight HTTP protocol. Therefore, since the resource request is sent based on the lightweight HTTP protocol, the lightweight HTTP protocol can be obtained by simplifying the HTTP protocol, thereby reducing the parsing overhead of the resource request. Since the first target static resource is obtained from the multiple static resources cached in the first memory according to the resource path indicated by the resource request when the resource type indicated by the resource request is a static resource, it is achieved to obtain the static resource from the cache, thereby eliminating the need for repeated calculations and reducing the processor load. In addition, the cached resources do not need to wait for back-end processing, shortening the response time and reducing latency. Since the dynamic resource is obtained by executing a dynamic processing request when the resource type indicated by the resource request is a dynamic resource, it is achieved to generate dynamic resources on demand, thereby improving the efficiency of dynamic content generation.

[0048] The following describes in detail the request processing method applied to an electronic device and the electronic device for processing requests provided in the embodiments of the present application in conjunction with the accompanying drawings.

[0049] First, combine Figure 1 , the request processing system to which the request processing method is applicable is explained. Figure 1 As an example, the request processing system shown in Figure 2 and Figure 3 , the request processing method provided in the embodiment of the present application is specifically described. Figure 2 A request processing method applied to an electronic device is described. Figure 3 This chapter describes the request processing method applied to the client. Figure 4 The electronic device for processing requests provided in the embodiments of the present application is described in detail.

[0050] It should be noted that the embodiments of the present application can be implemented independently or in combination with each other, and the same or similar concepts or processes will not be described in detail in some embodiments.

[0051] Figure 1 A block diagram of a request processing system according to an embodiment of the present application is shown.

[0052] like Figure 1 As shown, the request processing system may include a client, a physical interface of an Ethernet cable, a physical layer (PHY) transceiver, electronic devices, and components. The physical layer transceiver may also be referred to as a physical layer chip.

[0053] The electronic device may include an edge microserver. The edge microserver may include an embedded web server based on a single-chip microcomputer (i.e., a microprocessor). The electronic device may include a processor, a first memory, and a second memory. The device may include a programmable device or a non-programmable device. For example, the non-programmable device may include a sensor.

[0054] The first memory can be configured to cache multiple static resources. Furthermore, the first memory can be configured to cache precompiled templates and stored hash values ​​associated with the client. The processor can call init_pool() to allocate a memory pool and load the precompiled templates into the first memory. Furthermore, the first memory can be configured to store program code for the electronic device, such as an RTOS (Real-Time Operating System) or HTTP server logic. The first memory can be a non-volatile memory.

[0055] The second memory can be configured to store at least one of a protocol stack space, a cache pool, or a task stack. The protocol stack space can include a network protocol stack. For example, the LwIP (Light Weight IP) protocol stack. The cache pool can be configured to cache multiple dynamic resources, third-target static resources, or storage checksums for cached data. In addition, the cache pool can also be configured to cache parsed HTTP request headers. The cache pool can be implemented using a memory management unit or a static array. The task stack can allocate runtime stack space for RTOS tasks. For example, RTOS tasks can include HTTP service threads or sensor reading threads.

[0056] The client may be installed with various application programs, such as a browser program for processing requests. The client may be various electronic devices with a display screen and supporting web browsing, such as a tablet computer, a laptop computer, a desktop computer, or a smart phone.

[0057] The client can be configured to generate a resource request and connect to the physical interface of the Ethernet cable via an Ethernet cable to achieve communication with the physical layer transceiver. For example, the client sends a resource request based on the lightweight HTTP protocol to the physical layer transceiver via the Ethernet cable and the physical interface of the Ethernet cable.

[0058] The physical layer transceiver converts the received signal into a digital signal and then sends the digital signal to the electronic device.

[0059] An electronic device can communicate with a physical layer transceiver via an MII (Media Independent Interface) or an RMII (Reduced Media Independent Interface). The electronic device may also include a MAC (Media Access Control Address). For example, if the resource type indicated in the resource request is a static resource, the processor may retrieve a first target static resource from multiple static resources cached in a first memory according to the resource path indicated in the resource request, and send a first response message including the first target static resource to the client. If the resource type indicated in the resource request is a dynamic resource, the processor may execute a dynamic processing flow to obtain the dynamic resource and send a second response message including the dynamic resource to the client. The processor may be configured to control a device to obtain data related to the device. For example, the device may be a sensor. The data related to the device may be sensor data. Dynamic resources may include sensor data. The processor may obtain sensor data via an SPI (Serial Peripheral Interface) or an I2C (Inter-Integrated Circuit).

[0060] Figure 2 A flowchart of a request method applied to an electronic device according to an embodiment of the present application is shown. The electronic device may include a processor and a first memory. The request processing method may be executed by the processor.

[0061] like Figure 2 As shown, the method includes operations S210 to S220.

[0062] In operation S210, in response to a received resource request sent based on the lightweight HTTP protocol, when the resource type indicated by the resource request is a static resource, a first target static resource is obtained from multiple static resources cached in a first memory according to the resource path indicated by the resource request, and a first response information including the first target static resource is sent to the client.

[0063] In operation S220, when the resource type indicated by the resource request is a dynamic resource, a dynamic processing flow is executed to obtain the dynamic resource, and second response information including the dynamic resource is sent to the client.

[0064] The lightweight HTTP protocol can be obtained by simplifying the HTTP protocol. For example, the lightweight HTTP protocol can be obtained by removing non-core fields in the HTTP protocol. Non-core fields may refer to fields that are not related to embedded scenarios. Non-core fields may include at least one of the following: non-core header fields or non-core status codes. Non-core header fields may include at least one of the following: non-core header fields in the request header (for example, User-Agent or Accept-Encoding) or non-core header fields in the response header. Therefore, the lightweight HTTP protocol removes non-core fields in the HTTP protocol and retains other fields (i.e., core fields), thereby reducing the size of the HTTP protocol, reducing the parsing overhead of a single request and the storage overhead of the HTTP protocol, and reducing the complexity of the parsing state machine.

[0065] The core field may include at least one of the following: a core header field in a request header, a core header field in a response header, or a basic status code.

[0066] As an implementation, the request header of the lightweight HTTP protocol may include core header fields in the request header of the HTTP protocol. For example, the request header of the lightweight HTTP protocol may be composed of core header fields in the request header of the HTTP protocol. The core header fields in the request header may include at least one of the following: GET, POST, or Content-Length.

[0067] As another implementation, the response header of the lightweight HTTP protocol may include the core header fields in the response header of the HTTP protocol. For example, the response header of the lightweight HTTP protocol may be composed of the core header fields in the response header of the HTTP protocol.

[0068] As another implementation, the status code of the lightweight HTTP protocol can be a basic status code in the status line of the HTTP protocol. For example, the basic status code can include at least one of the following: 200 OK, 400 Bad Request, 403 Forbidden, 404 Not Found, or 500 Internet Server Error.

[0069] Furthermore, the lightweight HTTP protocol can also achieve connection reuse for high-frequency short-term connections by customizing keep-alive (i.e., Connection: keep-alive) to avoid frequent three-way handshakes. Keep-alive can be an extended header field used to control the persistence of the TCP connection between the client and the server.

[0070] Dynamic processing can be used to generate dynamic resources based on resource requests.

[0071] According to an embodiment of the present application, since the resource request is sent based on the lightweight HTTP protocol, the lightweight HTTP protocol can be obtained by simplifying the HTTP protocol, thereby reducing the parsing overhead of the resource request. Since the first target static resource is obtained from the multiple static resources cached in the first memory according to the resource path indicated by the resource request when the resource type indicated by the resource request is a static resource, it is achieved to obtain the static resource from the cache, thereby eliminating the need for repeated calculations and reducing the processor load. In addition, the cached resources do not need to wait for back-end processing, shortening the response time and reducing latency. Since the dynamic resource is obtained by executing a dynamic processing request when the resource type indicated by the resource request is a dynamic resource, it is achieved to generate dynamic resources on demand and improve the efficiency of dynamic content generation.

[0072] The following describes how to determine whether a resource type is static or dynamic, how to obtain static resources and optimizations related to static resources, how to obtain dynamic resources and optimizations related to dynamic resources, and security enhancement methods.

[0073] 1. How to determine whether the resource type is static or dynamic

[0074] The client can send a resource request to the electronic device based on the lightweight HTTP protocol. The processor of the electronic device can parse the resource request to obtain a request line and a request header.

[0075] As an implementation, the resource type can be determined as a static resource or a dynamic resource based on the request method indicated by the request line. For example, if the request method indicated by the request line is GET, the resource type is determined to be a static resource. If the request method indicated by the request line is POST or PUT, the resource type is determined to be a dynamic resource.

[0076] As another implementation, the resource type can be determined as a static resource or a dynamic resource based on the resource path indicated by the request line. For example, if the resource path indicated by the request line is a URL with parameters, the resource type is determined to be a dynamic resource. If the resource path indicated by the request line is a URL without parameters, the resource type is determined to be a static resource. The resource path of a dynamic resource can be mapped to a backend processing function. The resource path of a static resource can be mapped to a file system.

[0077] As another implementation manner, when the request header includes Content-Type or Content-Length, the resource type is determined to be a dynamic type.

[0078] 2. How to obtain static resources

[0079] The first memory of the electronic device can be configured to cache multiple static resources. Thus, when the resource type indicated by the resource request is a static resource, the processor of the electronic device can obtain the first target static resource from the multiple static resources cached in the first memory according to the resource path indicated by the resource request.

[0080] Thus, the first response information can be generated according to the first target static resource, and the first response information can be sent to the client based on the lightweight HTTP protocol.

[0081] 3. Optimization related to static resources

[0082] 3.1. Accelerate the parsing of static resource requests

[0083] Because the content and structure of static resources are relatively fixed, that is, the dynamic parameters in the static resources are less than or equal to the fourth predetermined threshold, and the request body is related to the dynamic parameters, if the resource type is a static resource, parsing of the request body can be skipped, and the first target static resource can be directly obtained from multiple static resources cached in the first memory based on the resource path indicated by the parsing result obtained by parsing at least one item in the request line or request header. Since there is no need to parse the request body, the parsing speed of static resource requests is improved and the parsing overhead of static resource requests is reduced.

[0084] As an implementation, a finite state machine (FSM) can be used to parse the resource request and obtain a parsing result. For example, a locating function can be used to locate a predetermined delimiter in the resource request. For example, the locating function can include strstr(). The predetermined delimiter can be "\r \r".

[0085] 3.2 Static Resource Optimization

[0086] Static resources may include at least one of the following: an HTML file or a compressed file. The compressed file may include at least one of the following: a CSS file or a client-side script file. Thus, the original HTML file may be optimized to obtain an HTML file. The file to be compressed is compressed to obtain a compressed file. The file to be compressed may include at least one of the following: an original CSS file or an original client-side script file.

[0087] The following describes the optimization of HTML files and files to be compressed.

[0088] 3.2.1 HTML file optimization

[0089] The original HTML file may be optimized to obtain the HTML file by at least one of the following implementations.

[0090] As an implementation, the first invalid character may include at least one of an invalid line break character and an invalid space. For example, an invalid line break character may refer to a superfluous line break character. An invalid space may refer to a superfluous space. Thus, the first comment or the first invalid character in the original HTML file may be deleted. For example, at least one of the first comment or the first invalid character may be deleted using a first regular expression. By deleting the first comment or the first invalid character in the original HTML file, the size of the original HTML file is reduced by 40% to 60%, thereby saving storage overhead.

[0091] As another implementation method, the nested tags in the original HTML file can be converted into single-line tags to obtain single-line tags in the HTML file. For example, the nested tags in the original HTML file can be merged into a single-line form to obtain a single-line tag. For example, the nested tag can be " text ". A single-line label can be " text ”.

[0092] Parsing nested tags requires processing more start and end tags and ensuring that the nesting relationship of the tags is correct. When parsing single-line tags, there is no need to frequently switch between different tags and verify the nesting relationship, and there is no need to process complex nesting relationships or attributes. Therefore, the parsing time and complexity can be reduced.

[0093] As another implementation, you can embed CSS files or client-side script files into the original HTML file. For example, you can embed an external CSS file into the original HTML file. <style>标签嵌入原始HTML文件。可以将外部客户端脚本文件通过<script>标签嵌入原始HTML文件。<script> 标签可以还是 HTML 中用于嵌入或引用客户端脚本的标签,使页面具备动态交互能力。

[0094] 由此,无需额外请求CSS文件或JS文件,进而可以减少请求CSS文件或客户端脚本文件的请求开销。

[0095] 3.2.2、待压缩文件优化

[0096] 待压缩文件可以包括以下至少一项:原始CSS文件或原始客户端脚本文件。可以通过以下实现方式中的至少一项实现对待压缩文件进行压缩,得到经压缩文件。

[0097] 作为一种实现方式,为了删除未使用的CSS选择器或JS函数,合并重复样式规则,可以对待压缩文件的作用域进行优化。例如,在待压缩文件为原始CSS文件的情况下,可以解析HTML文件,得到原始CSS文件中已使用类标识。根据已使用类标识,删除未使用CSS选择器。根据已使用类标识,合并重复样式规则,由此,得到CSS文件。例如,可以将.header{color:red}与.title {color:red}合并为.shared {color:red}。

[0098] 在待压缩文件为原始客户端脚本文件的情况下,可以根据HTML文件,构建针对原始客户端脚本的依赖图。根据依赖图,确定原始客户端脚本中未使用的函数或变量。删除与未使用的函数或变量关联的代码,得到客户端脚本文件。

[0099] 作为另一种实现方式,在待压缩文件为客户端脚本文件的情况下,令牌(即Token)类型可以包括以下至少一项:关键字、标识符、运算符、字面量、注释或无效字符。例如,标识符可以包括变量名或函数名中的至少一项。无效字符可以包括以下至少一项:无效空格或无效换行符。在待压缩文件为CSS文件的情况下,令牌类型可以包括以下至少一项:选择器、属性、值、注释、大括号或无效字符。

[0100] 可以对待压缩文件进行语法分析,得到多个令牌。例如,利用第二正则表达式处理待压缩文件,得到多个令牌。针对多个令牌中的任一令牌,可以执行以下操作中的至少一项:

[0101] 作为一种实现方式,在该令牌为无效令牌的情况下,删除该令牌。在该令牌为有效令牌的情况下,保留该令牌。无效令牌可以包括第二注释或第二无效字符中的至少一项。

[0102] 作为另一种实现方式, 目标变量名的长度可以小于变量名的长度。可以将至少一个有效令牌各自的变量名转换为至少一个有效令牌各自的目标变量名。针对至少一个有效令牌中的任一有效令牌,可以将该有效令牌的变量名转换为有效令牌的目标变量名。例如,可以利用采用哈希算法将有效令牌的变量名转换为有效令牌的目标变量名。

[0103] 通过对待压缩文件进行压缩,缩减了待压缩文件的体积,由此,降低了存储开销。

[0104] 3.3、静态资源缓存池

[0105] 第二存储器可以配置为缓存多个动态资源。第二存储器的访问速率可以大于第一存储器的访问速率。第三目标静态资源可以在第二预定时段的访问频率可以大于或等于第一预定阈值。例如,第三目标静态资源可以包括index.html(即网站的入口文件)或style.css等中的至少一项。style.css可以用于定义样式,控制HTML 元素的外观和布局。第一预定阈值和第二预定时段可以根据实际业务需求进行配置,在此不作限定。

[0106] 可以响应于电子设备的启动操作,向第二存储器预加载至少一个第三目标静态资源。例如,可以在电子设备启动的情况下,可以向第二存储器的预分配内存池中预加载至少一个第三目标静态资源。例如,预分配内存池可以为SRAM(Static Random-Access Memory,静态随机存取存储器)。

[0107] 在第一存储器满足预定缓存淘汰条件的情况下,可以根据缓存淘汰策略,从第一存储器存储的多个静态资源中淘汰第二目标静态资源。预定缓存淘汰条件可以用于触发缓存淘汰。

[0108] 预定缓存淘汰条件可以包括以下至少一项:容量达到第五预定阈值、第一数目达到第六预定阈值、使用率达到第七预定阈值或命中率小于或等于第八预定阈值。容量可以指示第一存储器的缓存容量。第五预定阈值可以是根据第一存储器的缓存容量确定的。第一数目可以指示第一存储器中静态资源的数目。第六预定阈值可以是根据第一存储器的缓存容量和静态资源的存储大小确定的。使用率可以指示容量与第一存储器的缓存容量之间的比值。命中率可以指示第二数目与第三数目之间的比值。第二数目可以指示与第一存储器对应的缓存命中数目。第三数目可以指示与第一存储器对应的访问数目。

[0109] 预定缓存淘汰策略可以包括以下至少一项:先进先出策略、最近最少使用策略、最少频率使用策略、最近最多使用策略、随机淘汰策略或低交互引用间隔策略。

[0110] 作为一种实现方式,预定淘汰缓存策略可以为最近最少使用策略,可以利用双向链表记录资源访问顺序,针对每次访问,可以将被访问节点移至链表头部。在第一存储器满足预定缓存淘汰条件的情况下,可以删除链表尾部节点指示的静态资源,即链表尾部节点指示的静态资源为第二目标静态资源。

[0111] 此外,还可以针对第一存储器的缓存命中率(即命中率)进行统计,得到缓存命中信息。缓存命中信息可以包括缓存命中率。例如,可以利用计数器确定第一存储器的缓存命中数目(即第二数目),根据缓存命中数目和与第一存储器对应的访问数目(即第三数目),确定缓存命中率(即命中率)。由此,可以根据缓存命中信息,调整第二存储器的预加载策略。例如,在缓存命中率小于或等于第八预定阈值的情况下,可以根据资源优先级,调整第二存储器的预加载策略。

[0112] 作为一种实现方式,可以根据资源访问时刻,确定在第三预定时段内被访问的静态资源的访问数目。将在第三预定时段内被访问的静态资源的访问数目大于或等于第九预定阈值的静态资源作为预加载至第二存储器的第三目标静态资源。

[0113] 作为另一种实现方式,可以根据资源访问时刻,确定在第四预定时段内被访问的静态资源的访问数目,以及在第五预定时段内被访问的静态资源的访问数目。第四预定时段和第五预定时段之间可以无交集。第四预定时段为第五预定时段之前的时段。根据在第四预定时段内被访问的静态资源的访问数目和在第五预定时段内被访问的静态资源的访问数目,确定访问差值大于或等于第十预定阈值的静态资源,将该静态资源作为预加载至第二存储器的第三目标静态资源。访问差值可以指静态资源在第五预定时段的访问数目与该静态资源在第四预定时段的访问数目之间的差值,且该静态资源在第五预定时段的访问数目大于该静态资源在第四预定时段的访问数目。

[0114] 4、针对如何获得动态资源

[0115] 第二存储器可以配置为缓存多个动态资源。可以在资源请求指示的资源类型为动态资源的情况下,触发中断服务例程。例如,可以通过通用输入输出接口(General-PurposeInput / Output,GPIO)中断触发电子设备响应,降低轮询带来的处理器资源开销。

[0116] 可以执行中断服务例程,得到资源请求指示的目标对象的目标数据。目标对象可以包括处理器或被处理器监测的器件中的至少一项。器件可以包括可编程器件或非编程器件中的至少一项。目标数据可以包括用于控制处理器的控制指令或处理器获取到的数据中的至少一项。例如,处理器获取到的数据可以包括传感器数据。

[0117] 可以响应于从第二存储器缓存的多个动态资源中获取到目标对象的缓存数据,在目标数据与缓存数据之间的差值的绝对值大于或等于第一预定阈值的情况下,将缓存数据替换为目标数据,并将目标数据缓存于第二存储器。由此,减少了无效数据的传输。第一预定阈值可以根据实际业务需求进行配置,在此不作限定。由此,可以根据目标数据,生成第二响应信息。

[0118] 此外,还可以利用预编译模板来生成动态数据。预编译模板可以是处理器将HTML模板转换为预定结构体得到的。预编译模板可以包括多个预定占位符。还可以构建预定占位符和数据之间的关联关系。

[0119] 由此,可以根据预定占位符和数据之间的关联关系,将目标数据写入多个预定占位符中的至少一个目标占位符,得到第二响应信息。例如,可以利用memcpy()或sprintf()将目标数据写入多个预定占位符中的至少一个目标占位符。

[0120] 通过将目标数据写入预编译模板中目标占位符的方式实现了动态资源的按需生成,降低实时解析开销。

[0121] 5、与动态资源相关的优化

[0122] 为了降低内存错误导致的第二存储器缓存的动态资源出现异常的概率,保证动态资源的完整性,第二存储器还可以配置为缓存缓存数据的存储校验码,由此,可以响应于从第二存储器缓存的多个动态资源中获取到目标对象的缓存数据,确定缓存数据的读取校验码。在存储校验码与读取校验码相同的情况下,可以说明缓存数据未出现异常,在此情况下,如果在目标数据与缓存数据之间的差值大于或等于第二预定阈值,则可以将缓存数据替换为目标数据。在存储校验码与读取校验码不相同的情况下,可以说明缓存数据出现异常,在此情况下,可以从第二存储器删除该缓存数据。作为一种实现方式,读取校验码可以是在从第二存储器获取缓存数据的情况下,利用循环冗余校验方法处理缓存数据的得到的。存储校验码可以是在将缓存数据缓存于第二存储器的情况下,利用循环冗余校验方法处理缓存数据得到的。

[0123] 此外,目标数据可以包括传感器数据。可以配置传感器数据的缓存有效期。如果超过缓存有效期,则需要重新采集传感器数据,由此,提高了传感器数据的有效性。

[0124] 此外,还可以利用非阻塞模式处理耗时操作,并通过状态机管理任务进度,以实现异步I / O处理。耗时操作可以包括以下至少一项:文件读操作、文件写操作或传感器读取操作等。

[0125] 此外,还可以在动态资源请求处理期间,限制处理器时间片,以使得主线程能够优先处理优先级更高的资源请求。例如,可以响应于动态资源请求的处理时长大于或等于第三预定阈值,暂停处理动态资源请求,以使得处理器可以处理优先级高于该动态资源请求的资源请求。例如,可以使得处理器的主线程可以处理优先级高于该动态资源请求的资源请求。

[0126] 6、安全增强方式

[0127] 第一存储器还可以配置为缓存与客户端关联的存储哈希值。存储哈希值可以用于验证客户端的身份。

[0128] 由此,可以响应于资源请求包括客户端的待验证身份信息,解码待验证身份信息,得到解码信息。确定解码信息的验证哈希值。再从第一存储中获取到与客户端关联的存储哈希值。在验证哈希值与存储哈希值相同的情况下,生成指示客户端的身份验证通过的第三响应信息。在验证哈希值与存储哈希值不相同的情况下,生成指示客户端的身份验证未通过的第三响应信息。

[0129] 此外,可以响应于客户端在预定时长的请求次数等于第三预定阈值,向客户端发送提示客户端降低请求频率的第四响应信息。第三预定阈值可以根据实际业务需求进行配置,在此不作限定。

[0130] 此外,处理器还配置为响应于接收到的基于轻量化HTTP协议的资源请求,在资源请求指示的接口类型为敏感接口的情况下,启动用于建立电子设备与客户端之间的加密连接操作,以提高安全性。例如,敏感接口可以包括登录页面。由于是在接口类型为敏感接口的情况下,执行加密连接操作,而并不是针对所有接口类型均执行该操作,因此,降低了资源消耗,由此实现了安全性与资源消耗之间的平衡。例如,可以利用传输层安全协议1.2(Transport Layer Security 1.2,TLS 1.2)来实现加密连接操作。

[0131] 此外,还通过内存保护单元防止越界访问,提高系统稳定性。

[0132] 7、静态内存池管理

[0133] 此外,还可以预配置多个固定大小的内存块,并构建空闲链表。可以从空闲链表获取内存块,释放时归还空闲链表。内存块结构可以包括数据区和管理信息。数据区用于存储实际数据。管理信息用于指向下一个空闲块的指针。管理信息可以用于链表管理。在电子设备启动的情况下,可以分配连续内存,例如,可以通过静态数组实现,并将连续内存划分为多个固定大小的内存块。将内存块通过链表连接起来,形成空闲链表。头指针指向第一个空闲块。从空闲链表获取内存块,并更新头指针,标记内存块的状态为已分配。可以将释放的内存块重新插入空闲链表头部,并将内存块的状态标记为未分配。内存块可以为第一存储器中的内存块,也可以为第二存储器中的内存块。

[0134] 由于内存块的大小固定,因此可以降低动态分配导致的内存碎片。

[0135] 此外,针对实时性要求较高的控制指令(例如,开关指令),可以基于UDP协议传输,以降低协议栈开销。针对可靠性要求较高的页面传输,可以基于TCP协议传输,以提高传输可靠性。

[0136] 图3示出了根据本申请实施例的应用于客户端的请求处理方法的流程图。

[0137] 如图3所示,该方法包括操作S310~S320。

[0138] 在操作S310,基于轻量化HTTP协议向电子设备发送资源请求,以使得电子设备响应于接收到的基于轻量化HTTP协议发送的资源请求,在资源请求指示的资源类型为静态资源的情况下,根据资源请求指示的资源路径,从第一存储器缓存的多个静态资源中获取第一目标静态资源。在资源请求指示的资源类型为动态资源的情况下,执行动态处理流程,得到动态资源。

[0139] 在S320,接收自电子设备生成的包括第一目标静态资源的的第一响应信息或生成的包括动态资源的第二响应信息。

[0140] 根据本申请的实施例,客户端可以显示第一响应信息或第二响应信息。

[0141] 以上说明了本申请实施例提供的应用于电子设备和客户端的请求处理方法。

[0142] 在上述内容的基础上,下面针对本申请实施例提供的请求处理进行整体说明。

[0143] 本申请实施例提供的请求处理方法,通过协议精简与静态池化,内存占用降低60%,可以支持同时处理大于或等于20个并发连接。可以支持模块化扩展(例如,增加MQTT(Message Queuing Telemetry Transport,消息队列遥测传输协议)),兼容主流IoT(Internet of Things,物联网)平台。HTML文件体积从12KB压缩至3.5KB,首屏加载时间缩短至0.8秒,传输效率提高了40%。事件驱动方式使得待机功耗降低至15mA。

[0144] 由此,本申请实施例的技术方案可以适用于小于或等于8KB RAM(Random AccessMemory,随机存取存储器)的单片机,由此,突破了Web服务器内存限制。通过内存保护单元防止越界访问,提高了系统稳定性。

[0145] 与前述应用于电子设备的请求处理方法的实施例基于相同的发明构思,本申请实施例还提供了一种用于处理请求的电子设备,实现本申请实施例提供的应用于电子设备的请求处理方法。电子设备包括用以实现请求处理方法的各个操作的电路。

[0146] 图4示出了根据本申请实施例的用于处理请求电子设备的框图。

[0147] 如图4所示,该电子设备400可以包括第一存储器410和处理器420。

[0148] 第一存储器410,可以配置为缓存多个静态资源。

[0149] 处理器420,可以配置为:

[0150] 响应于接收到的基于轻量化超文本传输协议发送的资源请求,在资源请求指示的资源类型为静态资源的情况下,根据资源请求指示的资源路径,从第一存储器缓存的多个静态资源中获取第一目标静态资源,并向客户端发送包括第一目标静态资源的第一响应信息。

[0151] 在资源请求指示的资源类型为动态资源的情况下,执行动态处理流程,得到动态资源,并向客户端发送包括动态资源的第二响应信息。

[0152] 根据本申请的实施例,轻量化超文本传输协议可以利用简化超文本传输协议得到的。动态处理流程可以用于基于资源请求生成动态资源。

[0153] 本申请还提供了一种计算机可读存储介质,该计算机可读存储介质可以是上述实施例中描述的设备 / 装置 / 系统中所包含的;也可以是单独存在,而未装配入该设备 / 装置 / 系统中。上述计算机可读存储介质承载有一个或者多个程序,当上述一个或者多个程序被执行时,实现根据本申请实施例的方法。

[0154] 根据本申请的实施例,计算机可读存储介质可以是非易失性的计算机可读存储介质,例如可以包括但不限于:便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本申请中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。例如,根据本申请的实施例,计算机可读存储介质可以包括ROM(只读存储器)和 / 或RAM和 / 或ROM和RAM以外的一个或多个存储器。

[0155] 本申请的实施例还包括一种计算机程序产品,其包括计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。当计算机程序产品在计算机系统中运行时,该程序代码用于使计算机系统实现本申请实施例所提供的请求处理方法。

[0156] 在该计算机程序被处理器执行时执行本申请实施例的系统 / 装置中限定的上述功能。根据本申请的实施例,上文描述的系统、装置、模块、单元等可以通过计算机程序模块来实现。

[0157] 在一种实施例中,该计算机程序可以依托于光存储器件、磁存储器件等有形存储介质。在另一种实施例中,该计算机程序也可以在网络介质上以信号的形式进行传输、分发,并通过通信部分被下载和安装,和 / 或从可拆卸介质被安装。该计算机程序包含的程序代码可以用任何适当的网络介质传输,包括但不限于:无线、有线等等,或者上述的任意合适的组合。

[0158] 在这样的实施例中,该计算机程序可以通过通信部分从网络上被下载和安装,和 / 或从可拆卸介质被安装。在该计算机程序被处理器执行时,执行本申请实施例的系统中限定的上述功能。根据本申请的实施例,上文描述的系统、设备、装置、模块、单元等可以通过计算机程序模块来实现。

[0159] 根据本申请的实施例,可以以一种或多种程序设计语言的任意组合来编写用于执行本申请实施例提供的计算机程序的程序代码,具体地,可以利用高级过程和 / 或面向对象的编程语言、和 / 或汇编 / 机器语言来实施这些计算程序。程序设计语言包括但不限于诸如Java,C++,python,"C”语言或类似的程序设计语言。程序代码可以完全地在用户计算设备上执行、部分地在用户设备上执行、部分在远程计算设备上执行、或者完全在远程计算设备或服务器上执行。在涉及远程计算设备的情形中,远程计算设备可以通过任意种类的网络,包括局域网(LAN)或广域网(WAN),连接到用户计算设备,或者,可以连接到外部计算设备(例如利用因特网服务提供商来通过因特网连接)。

[0160] 附图中的流程图和框图,图示了按照本申请各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,上述模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图或流程图中的每个方框、以及框图或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。

[0161] 本领域技术人员可以理解,本申请的各个实施例中记载的特征可以进行多种组合和 / 或结合,即使这样的组合或结合没有明确记载于本申请中。特别地,在不脱离本申请精神和教导的情况下,本申请的各个实施例中记载的特征可以进行多种组合和 / 或结合。所有这些组合和 / 或结合均落入本申请的范围。

[0162] 以上对本申请的实施例进行了描述。但是,这些实施例仅仅是为了说明的目的,而并非为了限制本申请的范围。尽管在以上分别描述了各实施例,但是这并不意味着各个实施例中的措施不能有利地结合使用。不脱离本申请的范围,本领域技术人员可以做出多种替代和修改,这些替代和修改都应落在本申请的范围之内。< / style>

Claims

1. An electronic device, characterized in that: include: a first memory configured to cache a plurality of static resources; as well as Processor, configured as: In response to a received resource request sent based on a lightweight hypertext transfer protocol, if the resource type indicated by the resource request is a static resource, obtaining a first target static resource from a plurality of static resources cached in the first memory according to a resource path indicated by the resource request, and sending first response information including the first target static resource to the client, wherein the lightweight hypertext transfer protocol is obtained using a simplified hypertext transfer protocol; When the resource type indicated by the resource request is a dynamic resource, executing a dynamic processing flow to obtain the dynamic resource, and sending a second response message including the dynamic resource to the client, wherein the dynamic processing flow is used to generate the dynamic resource based on the resource request; The electronic device further includes a second memory configured to cache a plurality of dynamic resources, and an access rate of the second memory is greater than an access rate of the first memory; Wherein, the processor is further configured to: In response to the resource type indicated by the resource request being the dynamic resource, triggering an interrupt service routine; executing the interrupt service routine to obtain target data of a target object indicated by the resource request, wherein the target object includes at least one of the processor and a device monitored by the processor; In response to acquiring cached data of the target object from a plurality of dynamic resources cached in the second memory, if a difference between the target data and the cached data is greater than or equal to a first predetermined threshold, replacing the cached data with the target data and caching the target data in the second memory; generating the second response information according to the target data; and Send the second response information to the client.

2. The electronic device according to claim 1, wherein The lightweight hypertext transfer protocol request header includes the core header field in the hypertext transfer protocol request header; and / or The status code of the lightweight hypertext transfer protocol is the basic status code in the status line of the hypertext transfer protocol; and / or The response header of the lightweight hypertext transfer protocol includes a core header field in the response header of the hypertext transfer protocol.

3. The electronic device according to claim 1 or 2, characterized in that: The processor is further configured to: Parsing at least one item in the request line or the request header in the resource request to obtain a parsing result; and In a case where the resource type indicated by the parsing result is the static resource, the first target static resource is acquired from a plurality of static resources cached in the first memory according to the resource path indicated by the parsing result.

4. The electronic device according to claim 1 or 2, characterized in that: The static resource includes at least one of the following: a hypertext markup language file, a cascading style sheet file, or a client script file; The processor is further configured to perform at least one of the following operations: Optimizing the original hypertext markup language file to obtain the hypertext markup language file; or The file to be compressed is compressed to obtain a compressed file, wherein the file to be compressed includes at least one of the following: an original cascading style sheet file or an original client script file, and the compressed file includes at least one of the following: the cascading style sheet file or the client script file.

5. The electronic device according to claim 4, characterized in that The processor is further configured to perform at least one of the following operations to optimize the original hypertext markup language file to obtain the hypertext markup language file: Deleting a first comment or a first invalid character in the original hypertext markup language file, wherein the first invalid character includes at least one of an invalid line break character and an invalid space character; Converting nested tags in the original HTML document into single-line tags; or The cascading style sheet file or the client script file is embedded in the original hypertext markup language file.

6. The electronic device according to claim 4, characterized in that The processor is further configured to: Optimizing the scope of the file to be compressed; and / or For any token among the multiple tokens obtained by parsing the file to be compressed, perform at least one of the following operations: In response to the token being an invalid token, deleting the token, and in response to the token being a valid token, retaining the token, wherein the invalid token includes at least one of a second comment or a second invalid character; or Convert the variable name of at least one of the valid tokens to a target variable name of at least one of the valid tokens, wherein the length of the target variable name is less than the length of the variable name.

7. The electronic device according to claim 1 or 2, characterized in that: The processor is further configured to: In response to the first memory satisfying a predetermined cache elimination condition, a second target static resource is eliminated from the plurality of static resources stored in the first memory according to a cache elimination policy.

8. The electronic device according to claim 1, wherein: The processor is further configured to: Acquire a precompiled template, wherein the precompiled template is obtained by the processor converting a hypertext markup language template into a predetermined structure, and the precompiled template includes a plurality of predetermined placeholders; and The target data is written into at least one target placeholder among the plurality of predetermined placeholders to obtain the second response information.

9. The electronic device according to claim 1, wherein: The processor is further configured to: In response to a startup operation of the electronic device, at least one third target static resource is preloaded into the second memory, wherein an access frequency of the third target static resource in a predetermined period is greater than or equal to a first predetermined threshold.

10. The electronic device according to claim 9, characterized in that The processor is further configured to: Adjusting a preloading strategy of the second memory according to cache hit information associated with the first memory.

11. The electronic device according to claim 1, wherein The second memory is further configured to cache a storage check code of the cached data; Wherein, the processor is further configured to: In response to acquiring cached data of the target object from a plurality of dynamic resources cached in the second memory, determining a read check code of the cached data; In response to the storage verification code being identical to the read verification code, the cache data is replaced with the target data if an absolute value of a difference between the target data and the cache data is greater than or equal to a second predetermined threshold.

12. The electronic device according to claim 1, wherein The processor is further configured to: In response to a processing time length of a dynamic resource request being greater than or equal to a third predetermined threshold, suspending processing of the dynamic resource request, wherein the dynamic resource request is a resource request indicating that the resource type is the dynamic resource.

13. The electronic device according to claim 1 or 2, characterized in that: The first memory is further configured to cache a stored hash value associated with the client, the stored hash value being used to verify the identity of the client; Wherein, the processor is further configured to: In response to the resource request including the identity information to be verified of the client, decoding the identity information to be verified to obtain decoded information; Determining a verification hash value of the decoded information; Obtaining a storage hash value associated with the client from the first storage; and In response to the verification hash value being identical to the stored hash value, third response information is generated indicating that the identity authentication of the client is successful.

14. A request processing method, characterized in that: Applied to the electronic device according to any one of claims 1 to 13, the method comprises: In response to a received resource request sent based on a lightweight hypertext transfer protocol, if the resource type indicated by the resource request is a static resource, obtaining a first target static resource from a plurality of static resources cached in a first memory according to a resource path indicated by the resource request, and sending first response information including the first target static resource to a client, wherein the lightweight hypertext transfer protocol is obtained using a simplified hypertext transfer protocol; and In the case where the resource type indicated by the resource request is a dynamic resource, a dynamic processing flow is executed to obtain the dynamic resource, and second response information including the dynamic resource is sent to the client, wherein the dynamic processing flow is used to generate the dynamic resource based on the resource request.

Citation Information

Patent Citations

  • Static resource file access method and device, storage medium and server

    CN116088957A