Page MenuHomePhabricator

Consider creating new Webpage objects through a method that maintains a cache
Closed, ResolvedPublic

Description

There may be cases where new Webpage objects are created for targets previously used. This may waste resources, because response caches (HTTP and Citoid) and the JSDOM tree would have to be maintained separately, once per Webpage instance. For example:

  • When TemplateConfiguration's loadConfiguration method is called, the array of TranslationTemplate objects is erased and replaced with the TranslationTemplates of the new configuration. However, the new configuration may contain translation templates for paths already in the previous (erased) configuration.
  • When a selection or transformation step is updated via a "replace" method (i.e., instead of mutating the object itself), the updated step may refer to the same external resource as before.

(note that in these examples the TranslationTemplate's template Webpage may have an empty cache; this would make more sense in cases where selection or transformation steps -not yet supported- that rely on external resources are used)

Consider creating new Webpage objects through a static Webpage method that maintains a cache of previously created objects and returns previously created instances if they already exists.

Event Timeline

diegodlh claimed this task.
diegodlh moved this task from Backlog to Done on the Web2Cit-Core board.

Fixed in test-configuration branch. Now Webpage objects are created via the getWebpage method of a WebpageFactory object included in the Domain objects.