Skip to content

Commit

Permalink
fix: default http_cache to false
Browse files Browse the repository at this point in the history
  • Loading branch information
fengkx committed Mar 9, 2021
1 parent 4366fa0 commit 375addb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 1 addition & 3 deletions source/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ export const config: Config = {
strict_ttl:
process.env.RSSBOT_STRICT_TTL !== '0' &&
process.env.RSSBOT_STRICT_TTL !== 'false',
http_cache:
process.env.RSSBOT_HTTP_CACHE !== '0' &&
process.env.RSSBOT_HTTP_CACHE !== 'fasle',
http_cache: !!process.env.RSSBOT_HTTP_CACHE || false,
notify_error_count: parseInt(process.env.NOTIFY_ERR_COUNT) || 5,
view_all: !!process.env.RSSBOT_VIEW_ALL || false,
UA:
Expand Down
18 changes: 10 additions & 8 deletions source/utils/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,16 @@ async function fetch(feedModal: Feed): Promise<Option<any[]>> {
const feedUrl = feedModal.url;
try {
logger.debug(`fetching ${feedUrl}`);
const res = await got
.get(encodeURI(feedUrl), {
headers: {
'If-None-Match': feedModal.etag_header,
'If-Modified-Since': feedModal.last_modified_header
}
})
.on('request', gotBugWorkaround);
const request = got.get(encodeURI(feedUrl), {
headers: {
'If-None-Match': feedModal.etag_header,
'If-Modified-Since': feedModal.last_modified_header
}
});
if (config.http_cache) {
request.on('request', gotBugWorkaround);
}
const res = await request;
if (res.statusCode === 304) {
const updatedFeedModal: Partial<Feed> & { feed_id: number } = {
feed_id: feedModal.feed_id,
Expand Down

0 comments on commit 375addb

Please sign in to comment.