Problem/Motivation

We have a leaflet view listing dozens of nodes with the same marker icon and we noticed that Drupal is fetching this icon with an HTTP request for each node.
It seems setFeatureIconSizesIfEmptyOrInvalid() is called on each feature even if the icon is always the same.

Steps to reproduce

  1. Create a leaflet view that returns several results.
  2. Set iconURL to a static PNG file.
  3. Watch the server logs.

Proposed resolution

We could add static cache to only fetch each icon file once.

Issue fork leaflet-3312282

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

prudloff created an issue. See original summary.

prudloff’s picture

Status: Active » Needs review

itamair made their first commit to this issue’s fork.

itamair’s picture

Version: 2.1.14 » 2.2.x-dev

  • itamair committed 19d9997 on 2.1.x
    Revert "Issue #3312282 by itamair: Cache icon size in...

  • itamair committed 9b22df8 on 2.2.x
    Issue #3312282 by prudloff, itamair: Cache icon size in...
itamair’s picture

Status: Needs review » Fixed

Very nice catch @prudloff ... definitely an improvement to implement.

But I had to struggle with your MR, that I closed as it was applying to the 2.1.x (and even not clean to the dev head) that is not supported any more. Also some of your code couldn't work properly to me, such as:

      if (isset($this->iconSizes[$feature["icon"]["iconUrl"]])) {
        $feature["icon"]["iconSize"]["x"] = $this->iconSizes[$feature["icon"]["iconUrl"]][0];
        $feature["icon"]["iconSize"]["x"] = $this->iconSizes[$feature["icon"]["iconUrl"]][1];
      }

I had to fix it and apply/commit into the 2.2.x branch with this: https://git.drupalcode.org/project/leaflet/commit/9b22df8
This is going to be part of the new 2.2.10 release ...

(please better QA and Test new MRs when you provide ... )

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.