ncbo / bioportal_web_ui

A Rails application for biological ontologies
http://bioportal.bioontology.org/
Other
21 stars 2 forks source link

analytic data is not getting cached. #207

Open alexskr opened 2 years ago

alexskr commented 2 years ago

Analytics data doesn't change frequently so it should be cached; however, UI keeps on making repeated calls to the backend to get analytics data. This adds unnecessary load on the backend.

When UI landing page is accessed we are seeing the following requests on the API side:

10.2.1.4 - ontoportal_ui [29/Jul/2022:18:39:41 +0000] "GET /mappings/statistics/ontologies HTTP/1.0" 200 17864 0.0066
10.2.1.4 - ontoportal_ui [29/Jul/2022:18:39:42 +0000] "GET /analytics?month=6&year=2022 HTTP/1.0" 200 2 0.5970

When /ontologies/ is repeatedly accessed:

10.2.1.4- ontoportal_ui [29/Jul/2022:18:33:42 +0000] "GET /ontologies/NCIT/analytics HTTP/1.0" 200 2 0.0079
10.2.1.4 - ontoportal_ui [29/Jul/2022:18:33:47 +0000] "GET /ontologies/NCIT/analytics HTTP/1.0" 200 2 0.0067
10.2.1.4- ontoportal_ui [29/Jul/2022:18:33:49 +0000] "GET /ontologies/NCIT/analytics HTTP/1.0" 200 2 0.0066
10.2.1.4 - ontoportal_ui [29/Jul/2022:18:33:51 +0000] "GET /ontologies/NCIT/analytics HTTP/1.0" 200 2 0.0073
alexskr commented 2 years ago

Perhaps this is a problem on the API side since API doesn't set proper caching headers:

# curl -I 'http://data.bioontology.org/ontologies/XCO/analytics'
HTTP/1.1 200 OK
Server: nginx/1.22.0
Date: Fri, 29 Jul 2022 19:19:12 GMT
Content-Type: application/json;charset=utf-8
Content-Length: 893
Connection: keep-alive
X-Rack-Cache: miss
Vary: Origin
X-Content-Type-Options: nosniff

Here is the call with cache control enabled:

# curl -I 'http://data.bioontology.org/ontologies/XCO'
HTTP/1.1 200 OK
Server: nginx/1.22.0
Date: Fri, 29 Jul 2022 19:13:15 GMT
Content-Type: application/json;charset=utf-8
Content-Length: 2835
Connection: keep-alive
Vary: User-Agent, Accept, Accept-Language, Accept-Encoding, Authorization, NCBO-Slice, NCBO-Cache, Origin
Cache-Control: public, max-age=3600
Last-Modified: Fri, 29 Jul 2022 01:43:52 GMT
X-Content-Digest: 5fdeb9fa15e121232b0f1e6e2aebc7d9f82fc838
Age: 0
X-Rack-Cache: miss, store
X-Content-Type-Options: nosniff