Skip to content

Commit

Permalink
Merge pull request #10167 from OutstandingWork/10051/No_Result_Cache
Browse files Browse the repository at this point in the history
Cache fulltext search results
  • Loading branch information
jimchamp authored Dec 23, 2024
2 parents bbd0617 + 6d945a9 commit f120cb8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions openlibrary/plugins/openlibrary/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,10 @@ def GET(self):
elif component == "FulltextSearchSuggestion":
query = i.get('data', '')
data = fulltext_search(query)
# Add caching headers only if there were no errors in the search results
if 'error' not in data:
# Cache for 5 minutes (300 seconds)
web.header('Cache-Control', 'public, max-age=300')
hits = data.get('hits', [])
if not hits['hits']:
macro = '<div></div>'
Expand Down

0 comments on commit f120cb8

Please sign in to comment.