- https://www.mathworks.com/help/matlab/ref/webread.html
- https://www.mathworks.com/help/matlab/ref/weboptions.html
how to get uncached data from webread
조회 수: 1 (최근 30일)
이전 댓글 표시
I am using the webread to get the data from the following api:
The data has been updated via the backend and it seems like i am getting a stale data
댓글 수: 0
채택된 답변
Chetan
2024년 5월 2일
I understand that you're using MATLAB's `webread` function to fetch updated data from an API but are receiving stale data despite backend updates.
As a workaround you can try the following steps:
1. Cache Issue: Append a unique query parameter to bypass potential caching, using the current timestamp as a cache buster.
cacheBuster = posixtime(datetime('now'));
url = sprintf('https://us-central1-techspardha-87928.cloudfunctions.net/api2/events/description?eventCategory=Programming&eventName=Productathon&cb=%d', cacheBuster);
data = webread(url)
2. Headers Adjustment: Use `weboptions` to set `Cache-Control: no-cache` in the request header.
options = weboptions('HeaderFields', {'Cache-Control','no-cache'});
url = 'https://us-central1-techspardha-87928.cloudfunctions.net/api2/events/description?eventCategory=Programming&eventName=Productathon';
data = webread(url, options)
3. Ensure the server's caching policies are correctly configured to serve the latest data.
Refer to the following MathWorks Documentation for more details:
Thanks
Chetan
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Web Services에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!