Ankush Menat
47fd3386fd
Revert "fix: Always reset globals on cached templates ( #30897 )" ( #30906 )
...
This reverts commit 32c1220c31 .
2025-01-28 10:02:00 +00:00
Ankush Menat
32c1220c31
fix: Always reset globals on cached templates ( #30897 )
2025-01-28 05:59:57 +00:00
Raffael Meyer
829a1404da
chore: bump actions/cache to v4 in boilerplate ( #30889 )
2025-01-27 12:01:09 +00:00
Ankush Menat
078330485c
fix: Re-update jinja globals on cached templates ( #30882 )
2025-01-27 07:08:25 +00:00
Ankush Menat
6ea200a48f
fix: handle typical client tracking errors
2025-01-25 10:15:50 +05:30
Ankush Menat
6328421fde
fix: only cache if called directly
2025-01-24 19:08:04 +05:30
Ankush Menat
378b638d34
feat: Decorator to cache API response using cache-control headers
2025-01-24 18:35:26 +05:30
Abdeali Chharchhodawala
bebc40087c
chore: Update raise_error_on_no_output documentation and example
2025-01-22 08:12:08 +00:00
Ankush Menat
e4a2b8db38
refactor: trim init.py ( #29866 )
...
* refactor: Trim `__init__.py`
We strayed from the goal here: https://github.com/frappe/frappe/pull/29181
So making up for it.
* chore!: Delete unused get_version
Not used anywhere
* refactor: move few more functions to relevant place
* asd
2025-01-20 13:05:02 +00:00
Ankush Menat
320798d390
perf: add cache-control headers on private files ( #29221 )
...
* perf: add cache-control headers on private files
- Client(browser) side cache
- 1 hr expiry
- 1 day revalidation
- etagged by nginx in default config (so no data transfer on expiry still)
In conjunction with https://github.com/frappe/agent/pull/157
* fix: Don't override existing headers
2025-01-17 18:51:34 +05:30
Ankush Menat
9ebfea1d08
perf: avoid duplicate template caching
2025-01-15 11:53:00 +05:30
Ankush Menat
829062b1e3
fix: make shared jenv thread-safe
...
A new copy is created for each request, but cache is shared.
2025-01-15 11:53:00 +05:30
Ankush Menat
2c2ec13874
perf: reuse jenv across requests
2025-01-15 11:53:00 +05:30
Akhil Narang
8b631dc0ed
Merge pull request #29156 from akhilnarang/partial-revert-26183
...
fix(csvutils): drop sniffer code
2025-01-15 11:20:18 +05:30
Akhil Narang
e5a3802dc5
feat(csvutils): make sniffer usage optional
...
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-01-15 10:58:41 +05:30
Ankush Menat
01f9787736
fix: catch template error for on-disk paths too
2025-01-14 20:04:36 +05:30
Ankush Menat
dc7636de8f
perf: use cached user document
2025-01-14 19:01:31 +05:30
Ankush Menat
80f324cc04
perf: cache simple jinja templates
2025-01-14 18:26:56 +05:30
Ankush Menat
a89fd99794
perf: keep jloader across requests
...
This doesn't have anything that needs to be created for each request.
2025-01-14 18:18:19 +05:30
Akhil Narang
d9b9940a79
fix(csvutils): drop sniffer code
...
This seems to break certain CSVs, which the default excel dialect can handle fine
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-01-14 17:19:13 +05:30
Ankush Menat
c72e91f465
fix: backward compatible date parsing ( #29155 )
...
Even though we never use tz aware object in frappe this function
previously used to retain them, so keep TZinfo for sake of compat.
Nothing should be affected ideally.
2025-01-14 11:05:55 +00:00
Ankush Menat
b6a0e849a0
fix: Avoid mixing client cache and redis_wrapper
2025-01-14 15:20:47 +05:30
Ankush Menat
b49d512404
feat: cache documents in client cache
...
No need to query 1 key at a time.
2025-01-14 14:33:10 +05:30
Ankush Menat
cde1662791
perf: use client side cache for assets.json
...
Single shared key, worth the costs.
2025-01-14 13:57:41 +05:30
Ankush Menat
4d1ef02e25
feat: generator support for client cache
...
Similar to redis, for ergonomics
2025-01-14 13:55:28 +05:30
Ankush Menat
fab464effb
feat: support shared keys in client cache
2025-01-14 13:52:29 +05:30
Ankush Menat
d46e2c20af
fix: Forward shared flag to cache generator ( #29146 )
...
Right now assets.json is read on every requests because of this bug.
2025-01-14 08:15:29 +00:00
Ankush Menat
2a5c778235
perf: speedup date parsing ( #29090 )
2025-01-09 06:55:13 +00:00
Ankush Menat
fdba41c682
perf: misc client cache improvements ( #29070 )
...
* perf: Reduce penalty for lack of redis connection
If redis isn't running than this client cache is slower than default
implementation because of the extra locking overhead.
* test: update perf redis counts
* perf: cache table columns in client-cache
* fix: race condition on cache-client_cache init
Rare but apparant in synthetic benchmarks.
Cache is set but client cache is still being initialized then request
will fail.
* perf: Don't run notifications when loading document
WHAT?
* fix: use cached doc to repopulate
* perf: reduce get_meta calls
2025-01-07 16:14:43 +05:30
Ankush Menat
b9c0662de6
fix: Make client cache work without redis too
2025-01-07 13:46:47 +05:30
Ankush Menat
06816f2817
perf: client-cache for defaults
2025-01-07 12:51:10 +05:30
Ankush Menat
33bd1bc09b
fix: Flushall shouldn't attempt reading keys
2025-01-07 11:56:22 +05:30
Ankush Menat
b5e2569c0c
feat: statistics for cache performance
...
These can be used for logging or debugging the behaviour of the cache.
2025-01-07 11:47:52 +05:30
Ankush Menat
8dd4ad53e2
fix: data race between GET and INVALIDATE
...
Fix for the documented example given here: https://redis.io/docs/latest/develop/reference/client-side-caching/#avoiding-race-conditions
2025-01-07 11:09:42 +05:30
Ankush Menat
c14d416d19
docs: add usage / notes in code
2025-01-06 19:28:37 +05:30
Ankush Menat
15f5adc25a
refactor: use namedtuple for readability
2025-01-06 19:28:33 +05:30
Ankush Menat
b51cfc1705
perf: minimize penalty for broken client cache
2025-01-06 18:57:57 +05:30
Ankush Menat
119af71ae3
refactor: variable names, force RESP2
2025-01-06 18:57:57 +05:30
Ankush Menat
98b1df7dac
fix: guard all writes with an RLock
2025-01-06 18:57:57 +05:30
Ankush Menat
53f085e0f4
test: ttl and maxsize
2025-01-06 18:57:57 +05:30
Ankush Menat
55ae5615d0
fix: clear all meta cache only when doctype is not specified
2025-01-06 18:57:57 +05:30
Ankush Menat
f332852415
fix: start tracking keys set by us immediately
2025-01-06 18:57:57 +05:30
Ankush Menat
f74ada155e
fix: Don't serve local cache values when it becomes unhealthy
2025-01-06 18:57:57 +05:30
Ankush Menat
45d414fe29
refactor: per-key TTL
2025-01-06 18:57:57 +05:30
Ankush Menat
21f0cda732
refactor: Reuse original cache connection
...
Drops redis connection per worker from 3 to 2!
Nothing wrong with doing this.
2025-01-06 18:57:57 +05:30
Ankush Menat
01cfa647a2
fix: set/del locally too
...
This is required if we do NOLOOP
2025-01-06 18:57:57 +05:30
Ankush Menat
e7139a1395
perf: store meta in client cache
2025-01-06 18:57:57 +05:30
Ankush Menat
cd47bee65e
fix: Avoid data races by accessing request specific cache
...
Imagine:
| client 1 | client 2 |
| --- | --- |
| rd(x) | |
| | wr(x) |
| inv(x) | |
| rd(x) | | <- This will end up using request specific cache!
2025-01-06 18:57:57 +05:30
Ankush Menat
764c3134cb
fix: expire client cache every 10 minutes
...
We can be more aggressive later, this is a good starting parting.
2025-01-06 18:57:57 +05:30
Ankush Menat
796e51df62
fix: limit # of keys by maxsize
...
Picking 1024 keys assuming 4kb avg size. In practice most things are
smaller so 1024 should be good enough!
This will likely only affect multitenant deploy with many sites.
2025-01-06 18:57:57 +05:30